Merge metrics from two hosts


I need help with a query to merge two series in influx.

After changing OS hostname on several systems, I noticed that telegraf “started over” with the metrics under a new “host”.

So before we had for example:

show series

And now it looks like this:

show series

How can I put these in to the series with the new hostname?

All help appreciated!

1 Like

@hasselrot You are going to need to pull the old data out and reinsert into the new series.

@jackzampolin How would I export the data in a format that I can “sed” and then import again?
Have tried many different ways but always seem to get invalid keys when I try to import it.

influx -database "telegraf" -format column -execute "select * from cpu where host='myhostname'" > backupfile

curl -i -XPOST 'http://localhost:8086/write?db=telegraf' --data-binary @backupfile

invalid field format\nunable to parse '1493221270000000000 cpu-total (times one hundred billions)

@hasselrot If you are trying to do it that way I’ve had the best luck with -format csv. Some quick vim or atom work should get you to something that you can import with the influx -import

@jackzampolin Is there any easier way you would rather recommend?
It seems the format of my export is not very close to the format I need to import…

I’ve hit this a few times (telegraf picking up renamed inputs), and need a straightforward method of merging two series.

I can’t believe I forgot this originally but you should be able to do this with a SELECT ... INTO query

jackzampolin, do you have an example of how to do this? For example, I changed a server name from “vader” to “” about a month ago. Now I need to merge the data from the last six months for “vader” and put this into the series for “”.