Delete measurements by name from bucket

Hey,

I am using InfluxDB 2.0 version and have setup a DB locally to get started.
For my use case I will be interacting with DB through python client only.

Able to query and write data but not been able to delete a measurement completely.
Can someone please help?

Tried this but it didn’t work: (command ran without error but I can still see measurements over UI)

from influxdb_client import InfluxDBClient, Point, WritePrecision

client = InfluxDBClient(url=$url, token=$token, org = $org)
query_api = client.query_api()

query = """from(bucket: "xxxx")
|> range(start: -50h)
|> drop(fn: (column) => column =~ /.*/)"""
query_api.query(query)

I hope I’m wrong, but it looks like that functionality might not be full completed yet in flux.

One workaround might be to use a Shell call to the influx client tool?

Hi @Subham_Modi,

the drop function removes specified columns from result of your query.

If you want to delete data, you should use DeleteApi - https://v2.docs.influxdata.com/v2.0/api/#/paths/~1delete/post. Something like this:

client = InfluxDBClient(url="http://localhost:9999", token="my-token", org="my-org")

delete_api = client.delete_api()
delete_api.delete('1970-01-01T00:00:00Z', '2020-04-27T00:00:00Z', '_measurement="my-measurement"', bucket="my-bucket", org="my-org")

Regards

2 Likes

Perfect. All i needed. Thanks a lot @bednar

Ya that would work but not exactly I would prefer as I would increase the complexity in my code.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.