Renaming of tags

147 views
Skip to first unread message

oc tsdb

unread,
Aug 2, 2013, 12:14:36 AM8/2/13
to open...@googlegroups.com
Hi,

We are having same tag-name/tag-values  for different metrics & we want to rename the tag-name/tag-values for a specific metric, How can we do this in TSDB?

Is there any command in which we can mention the metric name for which the tan-name/tag-values are to be changed?

Ex:


>>>>>>> Original values for metrics test_metric and test_metrics2 both store data under tag "ds_name=rename"
[root@oc-dev-2 tmp]# tsdb query 2010/01/01-00:00 sum test_metric2
test_metric2 1373928930 11 {ds_name=rename}
test_metric2 1373928935 112 {ds_name=rename}
test_metric2 1373928940 123 {ds_name=rename}
test_metric2 1373928945 21 {ds_name=rename}
test_metric2 1373928950 212 {ds_name=rename}
test_metric2 1373928955 223 {ds_name=rename}
[root@oc-dev-2 tmp]# tsdb query 2010/01/01-00:00 sum test_metric
test_metric 1373928930 11 {ds_name=rename}
test_metric 1373928935 112 {ds_name=rename}
test_metric 1373928940 123 {ds_name=rename}
test_metric 1373928945 21 {ds_name=rename}
test_metric 1373928950 212 {ds_name=rename}
test_metric 1373928955 223 {ds_name=rename}
[root@oc-dev-2 tmp]#

>>>>>>>>>>> renamed tagv from "rename" to "rename_new"
[root@oc-dev-2 tmp]# tsdb uid rename tagv rename rename_new
tagv rename -> rename_new
[root@oc-dev-2 tmp]# 

>>>>>>>>>>> now query the metrics again and see what happened to their data points
[root@oc-dev-2 tmp]# tsdb query 2010/01/01-00:00 sum test_metric
test_metric 1373928930 11 {ds_name=rename_new}
test_metric 1373928935 112 {ds_name=rename_new}
test_metric 1373928940 123 {ds_name=rename_new}
test_metric 1373928945 21 {ds_name=rename_new}
test_metric 1373928950 212 {ds_name=rename_new}
test_metric 1373928955 223 {ds_name=rename_new}
[root@oc-dev-2 tmp]# tsdb query 2010/01/01-00:00 sum test_metric2
test_metric2 1373928930 11 {ds_name=rename_new}
test_metric2 1373928935 112 {ds_name=rename_new}
test_metric2 1373928940 123 {ds_name=rename_new}
test_metric2 1373928945 21 {ds_name=rename_new}
test_metric2 1373928950 212 {ds_name=rename_new}
test_metric2 1373928955 223 {ds_name=rename_new}

>>>>>>>>> Try to read data for tagv "rename" on metric "test_metric2"
[root@oc-dev-2 tmp]# tsdb query 2010/01/01-00:00 sum test_metric2 ds_name=rename
Exception in thread "main" net.opentsdb.uid.NoSuchUniqueName: No such name for 'tagv': 'rename'
        at net.opentsdb.uid.UniqueId.getId(UniqueId.java:220)
        at net.opentsdb.core.Tags.resolveAllInternal(Tags.java:336)
        at net.opentsdb.core.Tags.resolveAll(Tags.java:310)
        at net.opentsdb.core.TsdbQuery.setTimeSeries(TsdbQuery.java:161)
        at net.opentsdb.tools.CliQuery.parseCommandLineQuery(CliQuery.java:242)
        at net.opentsdb.tools.CliQuery.doQuery(CliQuery.java:145)
        at net.opentsdb.tools.CliQuery.main(CliQuery.java:118)
[root@oc-dev-2 tmp]#

tsuna

unread,
Aug 2, 2013, 12:20:12 AM8/2/13
to oc tsdb, open...@googlegroups.com
On Thu, Aug 1, 2013 at 9:14 PM, oc tsdb <oc....@gmail.com> wrote:
> We are having same tag-name/tag-values for different metrics & we want to
> rename the tag-name/tag-values for a specific metric, How can we do this in
> TSDB?

You can't do this easily. Each tag name or tag value has an ID of its
own. If you rename a tag value, then you're just changing the name
associated with that ID. All the data points that use this tag value
ID will now point to the new name.

> Is there any command in which we can mention the metric name for which the
> tan-name/tag-values are to be changed?

No. What you would have to do is that you would have to delete+dump
all the data points for "test_metric" that have the tag you want to
change, then change the data, then re-import it:

tsdb scan --delete 2010/01/01-00:00 sum test_metric >/tmp/test_metric.txt
sed -i s/ds_name=rename/ds_name=rename_new/ /tmp/test_metric.txt
tsdb import /tmp/test_metric.txt

--
Benoit "tsuna" Sigoure

oc tsdb

unread,
Aug 2, 2013, 2:56:54 AM8/2/13
to tsuna, open...@googlegroups.com
Thanks for the reply.

But when I did it, I am getting some INFO logs followed by the data that is deleted, so when we try to import that , the import is failing.

Is there a way to suppress the INFO logs in the output of "tsdb scan --delete" by configuration changes to TSDB or is there any other way?

Thanks in advance.

tsuna

unread,
Aug 2, 2013, 3:08:13 AM8/2/13
to oc tsdb, open...@googlegroups.com
On Thu, Aug 1, 2013 at 11:56 PM, oc tsdb <oc....@gmail.com> wrote:
> Is there a way to suppress the INFO logs in the output of "tsdb scan
> --delete" by configuration changes to TSDB or is there any other way?

You'd need to change logback.xml to adjust the logging level, but in
this case you could simply just do this instead:

sed -i '/ds_name=rename/!d; s//ds_name=rename_new/' /tmp/test_metric.txt

--
Benoit "tsuna" Sigoure

Mike Dylan

unread,
Apr 8, 2015, 3:20:31 PM4/8/15
to open...@googlegroups.com, oc....@gmail.com
Hi Benoit:

I've post in group about my problem but I am not getting any answer. This is a very important part of my implementation and I really need help.

Let's say I have have this data:

pctcpu <time> 20 server=web01 app=Web dc=dc1

I like to change the app tag on this data point to this:

pctcpu <time> 20 server=web01 app=Web_Application dc=dc1

After I update the tags, I need to rebuild my tree so that each data point goes into the corresponding nodes. In Renational Data Base, I could just issue update command and it will change. Is it possible to do this in OpenTSDB, if yes, How would I do this?

ManOLamancha

unread,
Apr 23, 2015, 10:00:35 PM4/23/15
to open...@googlegroups.com, oc....@gmail.com
On Wednesday, April 8, 2015 at 12:20:31 PM UTC-7, Mike Dylan wrote:
Hi Benoit:

I've post in group about my problem but I am not getting any answer. This is a very important part of my implementation and I really need help.

Let's say I have have this data:

pctcpu <time> 20 server=web01 app=Web dc=dc1

I like to change the app tag on this data point to this:

pctcpu <time> 20 server=web01 app=Web_Application dc=dc1

After I update the tags, I need to rebuild my tree so that each data point goes into the corresponding nodes. In Renational Data Base, I could just issue update command and it will change. Is it possible to do this in OpenTSDB, if yes, How would I do this?

Also remember that time series data is a bit different from relational data in that, from your example before, when your host changed rolls from "app=Web" to "app=Web_Application", you don't actually WANT to rename the tag. I.e. at time T0 to T1, your host was actually serving that first app. But at T1 to T2 it's now hosting a different app. So all you do is start sending that new tag value at the time your web app changes. That way you can either look at the cpu history over time for the host, regardless of the app, or you can look at aggregated data over the app.
Reply all
Reply to author
Forward
0 new messages