How do I delete (drop) Influxdb2 measurements in Node red

How do I drop a measurement from a database in Influxdb2 ?

I have power and voltage data coming into Node-red then into Influxdb2 to Grafana and cannot figure out for the life of me how to drop/clear/delete complete measurements from Influxdb2 ?

Thanks Colin, You know I think I tried that but couldn't get in to work. I used the Influxdb In node with DROP MEASUREMENT "khdiff" Do you know the correct format to inject from Node red ?

The error NR gives is
HttpError: error @1:1-1:5: undefined identifier DROP

error @1:6-1:17: undefined identifier MEASUREMENT

It would need to be the influx Out node (not In), but I don't think you can do it that way. It is only for writing data.

It appeared to work, with no error but the data and measurement are still in Influxdb data explorer

I used
[ { "id": "acaaabad4c2375d5", "type": "inject", "z": "09cabf3a1bb1f9af", "name": "", "props": [ { "p": "query", "v": "DROP MEASURMENTS \"khdiff\"", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 270, "y": 1840, "wires": [ [ "4b9c4402fef72420" ] ] }, { "id": "4b9c4402fef72420", "type": "influxdb out", "z": "09cabf3a1bb1f9af", "influxdb": "a8a128447e7148d2", "name": "", "measurement": "khdiff", "precision": "", "retentionPolicy": "", "database": "database", "precisionV18FluxV20": "ms", "retentionPolicyV18Flux": "", "org": "organisation", "bucket": "bucket", "x": 480, "y": 1840, "wires": [] }, { "id": "a8a128447e7148d2", "type": "influxdb", "hostname": "", "port": "8086", "protocol": "http", "database": "database", "name": "Influxdb2", "usetls": false, "tls": "", "influxdbVersion": "2.0", "url": "", "rejectUnauthorized": true } ]

Also I logged in via protainer to Influx tried that way but it doesn't recognize 'DROP'

Did you actually call the bucket 'bucket' and the Organisation 'organisation' or are they just demo names?

Try something like;

influx delete --bucket bucket \
  --start '1970-01-01T00:00:00Z' \
  --stop $(date +"%Y-%m-%dT%H:%M:%SZ") \
  --predicate '_measurement="khdiff"'

Untried but in influx docs

I don't see anything in the help text for the influxdb out node that suggests that you can give it a query to run via msg.query.

Did you see the section in the docs about how to run influxql? Query data with InfluxQL | InfluxDB OSS 2.6 Documentation

I think I posted the nodes before added the details, the Organisation is 'group' and bucket 'buckett'

Daft question, where do I add the code you provided ?

Yes I saw that but couldn't figure it out, bit annoying when it wants a token ID when you can't re-list it other than clone that bucket. (I wonder why they design a new version of Influxdb)

Sorry, I have no idea what you mean by that.

There should be no problem using influxql in the command line to drop the measurement. It isn't really a node-red problem, but if you tell us what is happening we may be able to help.

Sorry, I should have explained some more. In the docs you linked, it looks like it needs a token ID and well as Organization and buckett to allow access to list etc - could be I'm just miss reading it all.

I think I've tried every conceivable combination of commands and input methods in the last few days to no avail ... Maybe I'll go back Influxdb 1.8 and abandon trying to update myself :wink:


Getting somewhere

influx delete --bucket buckett \
  --start '1970-01-01T00:00:00Z' \
  --stop $(date +"%Y-%m-%dT%H:%M:%SZ") \
  --predicate '_measurement="khdiff"'

Gets an 401 Authorization error within Protainer. I tried various combinations of --id --org at the end of the above but still no go

Yes influx v2 is a complete nightmare because it says that you get an Operator Token but I never have. I had to go into the UI and get an All Access token. However, I think you need to do this if you have not already done so

Provide required authentication credentials
To avoid having to pass your InfluxDB host, API token, and organization with each command, store them in an influx CLI configuration (config). influx commands that require these credentials automatically retrieve these credentials from the active config.

Use the influx config create command to create an influx CLI config and set it as active:

influx config create --config-name <config-name> \
  --host-url \
  --org <your-org> \
  --token <your-auth-token> \
Change InfluxDB URL
For more information about managing CLI configurations, see the influx config documentation.

Thanks Buckskin, I agree with making things secure but it's a right pain, I've tried an all access token but still can't get it to work. One thing I found early on was the 'Copy to Clipboard' in Influxdb doesn't work !, you have to copy and paste the tokens - that took me a while when you have stuff already in your copy buffer...

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