How to delete a tag from InfluxDB 2.1

I’m using Telegraf to pull metrics into InfluxDB, at some point I changed the hostname of one of the boxes Telegraf is monitoring and I wanted to purge all the data from before the hostname change and purge the old host tag too so it doesn’t show up anymore.

I think I’ve successfully deleted all the data points as I see no data in the web UI any more, using:

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

However despite the web UI saying “No Results”, it’s still finding the “oldhostname” tag and so showing it as available for filtering by “host”. I can’t work out, now that all the data linked to that tag is gone, how to delete the tag itself. I can’t find anything in any of the docs how to delete old tags and Google is drawing blanks.

Any suggestions?

Hello @js_pex,
Are you using InfluxDB Cloud or OSS?
Is this problem persisting?

Hey, yes this is still persisting. I’m using InfluxDB OSS.

This is still an issue. I wanted to created a tag named “main”, but due to an error I created tags named “m”, “a” and “i” - before my python loop got exhausted and made an exception. Only one point of each was created and I removed them from the bucket, but whenever I have a range spanning over those points - I can see them as valid tags.

I think I ran OSS 2.2 at that time and now I’m running OSS 2.4 - fortunately time has gone, and ranges are seldom covering the points anymore.

OSS v2.7.5 It continues to be a problem. The tag is never deleted.

this problem exists on 2.7.8 oss, 2 years and nothing.

4 year later…. InfluxDB v2.7.10…This problem is still so annoying!!!, I’m at the point where I’d be willing to pay someone if they can tell me how to remove this tag value. Just for kicks I just upgraded to InfluxDB v2.8.0 and its still the same the command deletes all the data points but the value is still left!

influx delete --bucket telegraf --org PBCSD -t token
–start ‘1970-01-01T00:00:00Z’
–stop $(date +“%Y-%m-%dT%H:%M:%SZ”)
–predicate ‘_measurement=“http_response” AND server=“https://broadcom.com”’

I even brute force wiped out all the metrics like this and it still persists

influx delete --bucket telegraf --org PBCSD -t token
–start ‘1970-01-01T00:00:00Z’
–stop $(date +“%Y-%m-%dT%H:%M:%SZ”)
–predicate ‘_measurement=“http_response”’

Update: I was finally able to find a way remove the leftover tags/keys from InfluxDB by rebuilding the Indexes.

This process is documented here Rebuild the TSI index | InfluxDB OSS v2 Documentation , but the commands have syntax errors and as of today this is what is listed and is wrong. “find . -type d -name index -exec -delete” this link was helpful in workaround https://community.hiveeyes.org/t/repair-influxdb-tsi-index-files/1107

I run influxDB in a docker container in linux so in general that made it difficult/impossible to simply stop influxd process without stopping the whole container in order to rebuild indexes. I had to do it on the docker host itself

While on a regular host the data is usually located at

/var/lib/influxdb2/engine/data/

on host where it runs in a docker container in my case it resides in (this may vary depending on your config)

/var/lib/docker/volumes/influxdb-volume/_data/engine/data

Either way One you figure out the Influxdb data path this process will force a build of the index and remove any key’s/tag’s no longer in use

Remove any metrics relating to the key(s) with a command such as:

influx delete --bucket telegraf --org PBCSD -t token \
–start ‘1970-01-01T00:00:00Z’ \
–stop $(date +“%Y-%m-%dT%H:%M:%SZ”) \
–predicate ‘_measurement=“http_response” AND server=“https://broadcom.com/”’

Rebuild Indexes

  1. Shutdown influxd / Stop container
  2. Navigate to appropriate data directly path (IE /var/lib/docker/volumes/influxdb-volume/_data/engine/data)
  3. Run this command: find . -type d -name index -exec rm -rf {} +
  4. Start InfluxDB. It will take a little longer to start as it rebuilds but afteward

Once re-started no more old Key’s/Tag’s

Hope this helps someone!

Must have looked for a answerfor this so many times - thanks a lot for taking the time returning with a solution!

Worked like a charm - finally!