Dynamic Tags in Telegraf

Hi @all,

I am looking for a solution to add dynamic tags to my metrics.
e.g. the host a virtual machine is running on can change during the runtime of telegraf, but it is crucial to label the metrics of my VMs with the host the VM is running on.

I found the option of environment variables as global tags, but I think they are only read at the start of telegraf - not during the runtime.

Has anyone have an idea or a similar usecase ?

Bye, Dirk

If you’re using vSphere to manage your VM’s then have you tried the Telegraf vSphere input plugin?

vSphere Plugin

The VM and Host measurements should already have the tag for esxhostname. I imagine if the VM moves host then the next time it reports in then you should get the latest tag value.

We’ve had some good usage out of it so far.

Hi phlib,

thanks a lot for your answer.
The vSphere Plugin works pretty fine, but in this case I am dealing with Oracle VM - and Oracle VM doesn’t give you much information about your VMs :wink:

Telegraf is running on the VM? If you send Telegraf a SIGHUP it will reload the configuration and restart plugins, and it should also check the hostname again.

Hi daniel,

thanks a lot. Yes, I think I will write some kind of watchdog that will restart telegraf/send SIGHUP in case it is necessary.

Bye, Dirk