Change tag value in InfluxDB

I have data that is inserted with host names. Annoyingly, I'm going to change the domain from .lan to .mydomain.com

Obviously, I would like to be able to search my historical data on a machine when it crosses this change.

Can I update the tag definition from machine.lan to machine.mydomain.com?

+5
source share
3 answers

Unfortunately, there is no way to change the tag names for historical data in InfluxDB.

+2
source

While @Michael's answer is true that you cannot change tag values โ€‹โ€‹using InfluxDB commands, however you can write a client script that can change the tag value by inserting โ€œduplicateโ€ in the dimension with the same time stamp, set of fields and tags, except that the search tag changes its value.

Point with invalid tag (in Line protocol format ):

cpu,hostname=machine.lan cpu=50 1514970123 

After launch

 INSERT cpu,hostname=machine.mydomain.com cpu=50 1514970123 

SELECT * FROM CPU will turn on

 cpu,hostname=machine.lan cpu=50 1514970123 cpu,hostname=machine.mydomain.com cpu=50 1514970123 

After the script runs all the INSERT commands, you need to drop the outdated series of points with the old tag value:

 DROP SERIES FROM cpu WHERE hostname='machine.lan' 

Of course, this is very inefficient (note, in particular, this error ), and if you need to update the tag value to another tag value, which other points that you do not want to delete already have , you cannot just DROP SERIES . Therefore, please vote for InfluxDB to implement tag renaming and, in particular, change tag values โ€‹โ€‹based on WHERE queries. Or consider an alternative time series database that allows you to use regular SQL, such as Timescale .

+1
source

There is already an open request to the GitHub function for this. https://github.com/influxdata/influxdb/issues/4157

The likely solution proposed by the inflow developer, if you want to go down the dump, change, re-import the path (cruel, but effective), this comment may help.

https://github.com/influxdata/influxdb/issues/3904#issuecomment-268918613

0
source

Source: https://habr.com/ru/post/1263702/


All Articles