Skip to content

How to delete a measurement from InfluxDB 2.x

Introduction

Deleting measurements with test data for example is not very complicated. You can do this with the InfluxDB v2 API or with the Influx CLI within the shell of the InfluxDB 2.x Docker container. Both options are described below.

How To

Remove measurement with InfluxDB v2 API

The InfluxDB v2 API makes it very easy to remove a measurement with cURL. And of course it is also possible to use tools like [[Node-RED - Access the InfluxDB API Using the HTTP Request Node|Node-RED]] or Pentaho to make an HTTP call to the API.

Run the following command:

# Open your terminal application
curl --request POST "http://<ip>:<port>/api/v2/delete?org=<organization>&bucket=<bucket>" \
--header 'Authorization: Token <token>' \
--header 'Content-Type: application/json' \
--data '{
"start": "1970-01-01T00:00:00Z",
"stop": "2030-12-31T23:59:00Z",
"predicate": "_measurement=\"<measurement>\""
}'
# IMPORTANT: Please read the instructions below
Instructions:
  • Required Replace <ip> and <port> with the IP address and port of InfluxDB. Usually port 8086 is used but my container is using port 3004
  • Required Replace <organization> with your own organization name. I used the name of my virtual machine for example
  • Required Replace <bucket> with your own bucket name. Because data of Home Assistant is stored I used homeassistant
  • Required Replace <token> with your own token
  • Required Replace <measurement> with the name of the measurement you want to delete

Remove measurement with Influx CLI

Another method to remove a measurement is via the shell of the InfluxDB container using the influx CLI.

Run the following commands:

# Open your terminal application
# Go to the shell of the container
sudo docker exec -it influxdb /bin/bash
# Delete the measurement
influx delete --bucket "<bucket>" --org "<organization>" --predicate '_measurement="<measurement>"' --start "1970-01-01T00:00:00Z" --stop "2030-12-31T23:59:00Z" --token "<token>"
# IMPORTANT: Please read the instructions below
Instructions:
  • Optional Replace docker with podman if needed
  • Required Replace <bucket> with your own bucket name. Because data of Home Assistant is stored I used homeassistant
  • Required Replace <organization> with your own organization name. I used the name of my virtual machine for example
  • Required Replace <measurement> with the name of the measurement you want to delete
  • Required Replace <token> with your own token

Favorites

Comments

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

    Copyright 2021- Fiction Becomes Fact