Merge two inputs in one measurement

Hi,

I’m testing telegraf to collect raspberry pi status, and send them to influxdb (I’m a newbie at both)

I can get “cpu” measurement with some fields “usage_*”

But in raspberry pi 4 i can get cpu temp reading a file:

[[inputs.file]] 
  files = ["/sys/class/thermal/thermal_zone0/temp"]
  name_override = "cpu.temp"
  data_format = "value"
  data_type = "integer"

and I can get a new measurement with the name “cpu.temp”

But I want to get temp inside cpu measurement.

If I use name_override “cpu”, i can get a field “value” in cpu measurement, but is it possible to change the name of the field from “value” to “temp”?

I’ve tested cpu.temp, cpu_temp, cpu/temp in name_override without success.

Thanks!

The value parser doesn’t allow you to set the field name, though this would be a nice addition. One option to work around this would be to use the rename processor. Another way is the multifile input which was designed to pulling multi field metrics out of the /proc and /sys directories. It would look something like this (untested):

[[inputs.multifile]]
  name_override = "cpu"
  base_dir = "/sys/class/thermal/thermal_zone0"

  [[inputs.multifile.file]]
    file = "temp"
    dest = "temp"
    conversion = "int"

Thanks, works perfectly!