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

**URL:** <https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631>\
**Category:** General\
**Tags:** database\
**Created:** [23 February 2023 12:38 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631 "2023-02-23T12:38:43Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [23 February 2023 12:38 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/1 "2023-02-23T12:38:43Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 February 2023 13:23 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/2 "2023-02-23T13:23:22Z")

</div>

> **[Manage your data using InfluxQL | InfluxDB Cloud Documentation](https://docs.influxdata.com/influxdb/v2.6/query-data/influxql/manage-data/#delete-measurements-with-drop-measurement)**
>
> Use InfluxQL data management commands to write and delete data.

---

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [23 February 2023 16:21 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/3 "2023-02-23T16:21:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 February 2023 16:52 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/4 "2023-02-23T16:52:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [23 February 2023 17:10 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/5 "2023-02-23T17:10:30Z")

</div>

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": "127.0.0.1", "port": "8086", "protocol": "http", "database": "database", "name": "Influxdb2", "usetls": false, "tls": "", "influxdbVersion": "2.0", "url": "http://192.168.2.200:8086/", "rejectUnauthorized": true } ]`

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

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [23 February 2023 20:38 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/6 "2023-02-23T20:38:54Z")

</div>

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

Try something like;

```auto
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

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [23 February 2023 21:54 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/7 "2023-02-23T21:54:50Z")

</div>

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.

> [@myozone](#):
>
> I logged in via protainer to Influx tried that way but it doesn't recognize 'DROP'

Did you see the section in the docs about how to run influxql? [Query data with InfluxQL | InfluxDB OSS v2 Documentation](https://docs.influxdata.com/influxdb/v2.6/query-data/influxql/)

---

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [24 February 2023 09:48 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/8 "2023-02-24T09:48:37Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [24 February 2023 10:05 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/9 "2023-02-24T10:05:29Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [24 February 2023 10:16 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/10 "2023-02-24T10:16:35Z")

</div>

> [@myozone](#):
>
> bit annoying when it wants a token ID when you can't re-list it other than clone that bucket

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.

---

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [24 February 2023 10:28 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/11 "2023-02-24T10:28:30Z")

</div>

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 😉

**UPDATE**

Getting somewhere

```auto
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

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [24 February 2023 23:20 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/12 "2023-02-24T23:20:12Z")

</div>

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

```auto
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 http://192.168.1.20:8086 \
  --org <your-org> \
  --token <your-auth-token> \
  --active
Change InfluxDB URL
For more information about managing CLI configurations, see the influx config documentation.

```

---

<div class="post-metadata">

**Author:** ![myozone](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/myozone/32/8904_2.png) [@myozone](https://discourse.nodered.org/u/myozone)\
**Post date:** [25 February 2023 09:43 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/13 "2023-02-25T09:43:20Z")

</div>

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...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 April 2023 09:43 UTC](https://discourse.nodered.org/t/how-do-i-delete-drop-influxdb2-measurements-in-node-red/75631/14 "2023-04-26T09:43:38Z")

</div>

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