I have data being inserted that uses host names. Annoyingly I'm about to change a domain from .lan to .mydomain.com
Obviously I'd like to be able to search my historical data of a machine as it crosses this change.
Can I update a tag definition from machine.lan to machine.mydomain.com?
The tag key location has two tag values: 1 and 2 . The tag key scientist also has two tag values: langstroth and perpetua . In the data above, the tag set is the different combinations of all the tag key-value pairs. The four tag sets in the sample data are: location = 1 , scientist = langstroth.
InfluxDB lets you specify fields and tags, both being key/value pairs where the difference is that tags are automatically indexed. Because fields are not being indexed at all, on every query where InfluxDB is asked to find a specified field, it needs to sequentially scan every value of the field column.
InfluxDB as a key-value store As a cutting-edge time series database, InfluxDB borrows some ideas from key-value database designs. Earlier versions of InfluxDB actually provided support for RocksDB as a storage engine.
While @Michael's answer is correct in that you can't change tag values via InfluxDB commands, you can however write a client script that can change the value of a tag by inserting "duplicate" points in the measurement with the same timestamp, fieldset and tagset, except that the desired tag will have its value changed.
Point with wrong tag (in Line Protocol format):
cpu,hostname=machine.lan cpu=50 1514970123
After running
INSERT cpu,hostname=machine.mydomain.com cpu=50 1514970123
a SELECT * FROM CPU would include
cpu,hostname=machine.lan cpu=50 1514970123
cpu,hostname=machine.mydomain.com cpu=50 1514970123
After the script runs all the INSERT commands, you'll need to drop the obsolete series of points with the old tag value:
DROP SERIES FROM cpu WHERE hostname='machine.lan'
Of course, this is highly inefficient (note in particular this bug) and if you need to update a tag value to another tag value that other points you don't want to drop already have, you can't just DROP SERIES
. So please vote for InfluxDB to implement tag renaming and in particular, changing tag values based on WHERE
queries. Or consider an alternative time-series database that lets you use regular SQL, such as Timescale.
Unfortunately, there isn't a way to change tag names for historical data in InfluxDB.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With