Influxdb: [feature request] RENAME TAG

Created on 17 Sep 2015  路  44Comments  路  Source: influxdata/influxdb

From https://github.com/influxdb/influxdb/issues/828#issuecomment-83224779

e.g. RENAME TAG foo TO bar ON measurement

Would have to update all CQs, too.

1.x kinfeature-request

Most helpful comment

If you're about to leave a "+1" comment, please stop. Click the emoji icon of one of the messages in this thread that you agree with, and choose :+1: there.

All 44 comments

Out of curiosity, what's a CQ?

Continuous query.

Aha, thanks =).

+1, I love this feature

+1

What about changing the tag value?

:+1:

We need both , tag key change and also tag value change !

Lots of thanks for this awesome tool.

+1

@toni-moreno I have a perfect use case as to why I need to be able to change values.
I use collectd to pull in my SNMP values. I performed a firmware upgrade on a line of switches and the ifDesc field name changed on all 8 switches. So now all of the type_instance tag values are different. For example for interface 32 on switch 1 the ifDesc used to be "TenGigabitEthernet 1_0_32" but now that interface is "TenGigabitEthernet 0_32"
So the graphs and data retention are broken. Being able to alter/rename/update all tags from before the firmware update would allow the data to be linked up.

+1

I have same use case about SNMP values and waiting for long time for this feature. In the meantime, I dump series, rename tag value with sed and import again, but it's very slow process when I have many interfaces changes.

+1. I can't find a workaround. I can workaround the measurement and field rename, but not the tag.

Eg.
SELECT "old_field_key" AS "new_field_key" INTO new_measurement FROM old_measurement GROUP BY "old_tag_key"
renames field key and measurement, but cannot be extended to rename the tag key.

I'm having the exact same problem as hraftery piecing together data from two databases that contain data about the same measurement but with different names. Another solution would something like

Select sum(value) as value, counter=blub into newmeasurement

so I can tag the new data that going into newmeasurement.

Have anybody found a proper way or a workaround? I am also having the same issue. I renamed a host and now I need to merge the old tagged value of the host with the new one. Is that possible?
Thanks
George

same here is there a workaround? In my case the scheme changed, and I need to rename a tag like renaming a column name

+1 must have feature

@beckettsean any update on this?

+1 (really not seeing how this has not been implemented yet, essential as it seems dealing with historical data)

Any update on this? We have a use case of updating existing tag values as well.

How about updating a tag for points matching a query?

In the Key Concepts sample data, imagine that one of the scientists mistakenly recorded the location for measurements between timeA and timeB as 1 instead of 2. How can we update those points? Overwriting with the same (measurement name, time, tag set) tuple can only be used to update fields, not tags.

+1

Newbie alert: I'm a little unclear about the scope of this feature request. Does it cover two related but different capabilities?:

  1. Be able to rename a tag _key_ for all series in a measurement. E.g. for Key Concepts sample data, rename "location" -> "place"
  2. Be able to change the a tag _value_ for a one or more series in a measurement. E.g. for Key Concepts sample data, UPDATE census SET "scientist"="perpetua" WHERE "scientist"="miller" (e.g. person changed their last name)

The RENAME TAG foo TO bar ON measurement suggestion from the OP description seems to describe the first situation but not the second.

For our purposes, the second situation, rename a tag _value_ is by far the most important.

Should this issue really be split in two? Is it the same implementation to support both _tag key_ and _tag value_ changes or are the implementations independent? Which is the most difficult to achieve?

This issue is definitely about the tag _key_. It's one of a group of issues about renaming keys that used to be one issue.

As dandv and you say, changing tag _values_ is also a challenge, but deserves its own issue because the implications are different. As discussed on StackOverflow and Google Groups, there's no good solution to that either, short of re-inserting all the data and dropping the old. The implication is that tag values form _series_, so changing a tag value could change the database cardinality. While changing a tag key only affects the metadata.

If you want to go down the dump all, modify, re-import path (brutal, but effective), this comment might help.

This would be an awesome feature. Right now migrating data when a tag value changes is not really possible.

+1

+1

+1 waiting :)

+1

+1

As well as changing the tag value.

+1

As well as changing the tag value.

+1

+1

If you're about to leave a "+1" comment, please stop. Click the emoji icon of one of the messages in this thread that you agree with, and choose :+1: there.

Hi There,
Any news about this issue ?

+1

Any chance that it will be in 2.x?

+1

+1

+1

Rather than +1 in comments it is way better to react with 馃憤 under the initial comment.
There are many people who have subscribed to this issue to receive a notification when it will be closed (hopefully implemented), and those +1 only create unnecessary noise for everyone.

SELECT "old_field_key" AS "new_field_key" INTO new_measurement FROM old_measurement GROUP BY "old_tag_key"

The GROUP BY syntax seems the most intuitive to me.

In the meantime, a nice workaround I've found is to use Python and the aioinflux package.
To rename the host tag to host2:

async with aioinflux.InfluxDBClient(host='influxdb', db='mydb', output='dataframe') as client:
    df = await client.query("SELECT host as host2,* FROM measurement")
    delete df['host']
    await client.write(df, measurement="measurement_new", tag_columns=["host2"])

I've got a Jupyter Notebook instance running on the same machine as influxdb, which makes workarounds like this quite painless.

+1

+1

Hello,

Altering metadata is a major limitation of InfluxDB. Since InfluxQL does not support alter query types for measurements, tags or fields, I decided to implement a tool as a workaround.

The tool supports a RenameTag rule to rename a tag key from a measurement. It is an offline tool, so the node must be taken down first (the exact same way you would run influx_inspect buildtsi).

Please check it and let me know if it helps.

https://github.com/Abc-Arbitrage/infix

Any feedback is also welcome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dtouzeau picture dtouzeau  路  3Comments

shilpapadgaonkar picture shilpapadgaonkar  路  3Comments

deepujain picture deepujain  路  3Comments

756445638 picture 756445638  路  3Comments

Witee picture Witee  路  3Comments