Commad to delete a particular series from influxdb

  • What is the command to delete a particular series[i.e., for example out of 10 servers I need to delete one particular server] from influxdb?

  • Influxdb version which we are using is “1.5.2”.

  • Following are the commands which we followed to delete a particular series
    drop series from metric_name where host = ‘hostname’
    delete from metric_name where host = ‘hostname’

  • I went through the influxdb documentation link, but this did not help.

The link you’ve referred to has done the trick for me in the past.

Why did it not help? Can you paste the full command you’ve tried, and whether you’ve encountered an error?

  • Following are the commands which I have performed to delete a series
    drop series from metric_name where host = ‘hostname’
    delete from metric_name where host = ‘hostname’
  • No, I didn’t encounter any error.
  • If possible, can you please paste the command which you have used in the past to delete a series?

Thanks!

This is simply what I’ve run and it seems to have worked:

DROP SERIES FROM "measurement" WHERE "tag" = 'value'
  • I have performed the following command, but it doesn’t work, is there any other command other than this. Can you please help us. Thanks!
    DROP SERIES FROM “measurement” WHERE “host” = ‘hostname’

it seems like you’re not understanding what a measurement is. here’s an example from my setup.

First I ssh to my influxdb server, launch influx CLI and show the databases.

jjensen@host:~$ influx
Connected to http://localhost:8086 version 1.5.2
InfluxDB shell version: 1.5.2
> show databases
name: databases
name
----
_internal
snmp_brcd
snmp_any2
snmp_bip
snmp_bip_an
snmp_wdm
snmp_tdm
snmp_pdu

Next I’ll use the database that contains the series I want to drop. From here I can inspect the measurements. Right now I only have a single measurement - you might have more if you’re using telegraf.

> use snmp_brcd
Using database snmp_brcd
> show measurements
name: measurements
name
----
ifMIB_basics
>

Next I can inspect the series. The series will always be prefixed by the measurement name, followed by a comma.

> show series
key
---
ifMIB_basics,device=REDACTED,ifName=ethernet1/1,role=CORE,site=DC1
ifMIB_basics,device=REDACTED,ifName=ethernet1/2,role=CORE,site=DC1
ifMIB_basics,device=REDACTED,ifName=ethernet1/3,role=CORE,site=DC1
ifMIB_basics,device=REDACTED,ifName=ethernet1/4,role=CORE,site=DC1
ifMIB_basics,device=REDACTED,ifName=ethernet1/5,role=CORE,site=DC1
...

To make things more clear, the output of SHOW SERIES is formatted like so:

> show series
key
---
ifMIB_basics,device=REDACTED,ifName=ethernet1/1,role=CORE,site=DC1
^            ^      ^        ^      ^           ^    ^    ^    ^
m            tk     tv       tk     tv          tk   tv   tk   tv

m  = measurement
tk = tag key
tv = tag value

If I want to drop all series from the ifMIB_basics measurement that match the device name “REDACTED” then I would do:

> DROP SERIES FROM "ifMIB_basics" WHERE device='REDACTED'

Or if I wanted to drop all series from the ifMIB_basics measurement that match on the role name of “CORE” then I would do:

> DROP SERIES FROM "ifMIB_basics" WHERE role='CORE'

Or if I wanted to drop all series from the ifMIB_basics measurement that match the site of “DC1” then I would do:

> DROP SERIES FROM "ifMIB_basics" WHERE site='DC1'

If you have multiple measurements but the tag key host exists in all of them, you can drop the series from all measurements by doing:

> DROP SERIES WHERE "host" = 'your_hostname_here'

Note that per the documentation, the DROP SERIES query will always return an empty result, so you’ll need to verify that the command was successful on your own, either by issuing a SELECT or SHOW SERIES or other query.

3 Likes

Tried the following command, which gave the output as below -
Command: show tag values from measurement_name with key=host;
key value


host testing
host Avinash
host seshu
host Karthik
host Venky
host harsha
host anil
host avi

And based on the key value tried to delete series from a metric using.
Command: drop series from measurement_name where host=harsha;
Even after performing the below command the series is not being deleted.
Thank you,

You need to include your tag value in quotes.

>  drop series from "measurement_name" where host='harsha'

After performing the command: drop series from “measurement_name” where host=‘harsha’ also it is not deleting.

Thank you!

You said you want to delete from telegraf, correct?

Have you stopped the telegraf agent on the host harsha? If you haven’t done this, then even if you drop the series, the telegraf agent on the host will likely still be still sending data to InfluxDB, giving you the impression that the DROP SERIES query wasn’t actually successful.

Make sure you actually stop the telegraf agent on the harsha host first.

Connect to your influx server, start the influx CLI, then run:

> use telegraf

> show series where host='harsha'

> drop series where host='harsha'

Then run the SHOW SERIES query again:

> show series where host='harsha'

The second time you run SHOW SERIES you should not be getting any results back.

1 Like

Is there a command to delete series permanently. The above commands are just truncating the data.

Thanks!

DROP SERIES IS permanent.

You’re obviously not following my instructions.

As long as the telegraf agent on host harsha is still sending metrics to InfluxDB, then all the series are getting created again despite you dropping them previously.

1 Like
jjensen@host:~$ influx
Connected to http://localhost:8086 version 1.5.2
InfluxDB shell version: 1.5.2
> create database dummy
> use dummy
Using database dummy
> INSERT dummy_measurement,host=harsha some_value=1
> INSERT dummy_measurement,host=harsha some_value=2
> INSERT dummy_measurement,host=harsha some_value=3
> INSERT dummy_measurement,host=harsha some_value=4
> INSERT dummy_measurement,host=harsha some_value=5
> INSERT dummy_measurement,host=harsha some_value=6
> INSERT dummy_measurement,host=harsha some_value=7
>
> show series
key
---
dummy_measurement,host=harsha
> select * from dummy_measurement
name: dummy_measurement
time                host   some_value
----                ----   ----------
1529507904004212958 harsha 1
1529507905315150762 harsha 2
1529507906266940560 harsha 3
1529507907371478346 harsha 4
1529507908498060630 harsha 5
1529507909547188977 harsha 6
1529507911006787481 harsha 7
> show series where host='harsha'
key
---
dummy_measurement,host=harsha
> drop series where host='harsha'
> show series where host='harsha'
>
1 Like

Thank you very much. It work’s.

I’m also seeing DROP SERIES followed by SHOWing the same series, still not deleting the series. Nothing recreates it - a SELECT * proves that by showing nothing.

image

Hi @dandv ,

does it work when you escape all spaces in the where clause …
where symbool = ‘YUM\ FUT\ 20191220\ x5’ …