Using serial number instead of host name to identify the Telegraf agent in system input plugin

Hi, I am trying to use Telegraf agent to monitor multiple devices by means of system input plugin (telegraf/plugins/inputs/system at master · influxdata/telegraf · GitHub). I would like to have a way to uniquely identify each device that is pushing data into InfluxDB. I have seen that Telegraf uses hostname as a way to identify each agent and this variable can be overridden. Is there any way to use hardware serial number to uniquely identify it (like BIOS serial number)? I am fine modifying the code of the system plugin implementation and recompiling it.

Thanks for your time.

It would be possible if that serial number is available somewhere…

Otherwise, I would just set the hostname to the serial number or add it as a global tag in the config.

The serial number is available from inside the input system plugin, the dependencies that it is using allow to query the serial number: gopsutil/host_linux.go at c4a0f4689f12914053ab0a62ab6f37dfb36a6807 · shirou/gopsutil · GitHub

Great, you could add a PR that adds this info as a tag (disabled by default, but could be enabled by config flag).

You mean adding a new tag on each request? For example:

Adding here (telegraf/system.go at 0dd99b2157d3cc4338cda94efd945ea5a46cc402 · influxdata/telegraf · GitHub) a new field like:

"serial_number": getSerialNumber(),

Would it be fine?

Yes, but as a tag, not a field.

It would make sense to me, not sure what others think…

What is the difference between tag and field? And how can I add a tag from code?

Do you have an example for tagging from code?

Like any input that produces tags, Its just matter of also adding an item in the tags array as you would do to the fields array.