Merge metrics from two hosts

Hi!

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
system,host=nginx-server

And now it looks like this:

show series
system,host=nginx-server
system,host=nginx-server-newhostname

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

All help appreciated!
Lars

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.

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

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

Result:
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
command.

@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 “vader.domain.com” 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 “vader.domain.com”.