Rename dinamically

Is it possible for telegraf,
rename a field with a string value that the same script got from the agent?
example:
name |data
data1 | 33
data2 | 22
and also :
dataA | temperature
dataB | temperature_ext

telegraf could send to influx :slight_smile:
temperature |33
temperature_ext|22

Hello @tinyG,
Is that a JSON that you have?
What input format do you have?
You could use processors.converter and processors.rename

Or maybe just rename actually.

# Input plugin to gather data
[[inputs.file]]
  files = ["/path/to/input/file.json"]  # Replace with your data source
  data_format = "json"

# Rename fields based on mapping
[[processors.rename]]
  [[processors.rename.replace]]
    field = "data1"
    dest = "temperature"

  [[processors.rename.replace]]
    field = "data2"
    dest = "temperature_ext"

# Output plugin to send data to InfluxDB
[[outputs.influxdb_v2]]
  urls = ["http://localhost:8086"]
  token = "your-token"
  organization = "your-org"
  bucket = "your-bucket"

Assuming they’re all fields.
Does that help?

Thank you for replies,
I tried to check telegraf/docs/CONFIGURATION.md at master · influxdata/telegraf · GitHub
override / rename
in my case:
[[inputs.snmp.field]]
name = “interface_name_2”
oid = “.1.3.6.1.2” #( <— just an example ! )
#now in “interface_name_2” I got “WAN_b” (it is a string)

[[inputs.snmp.field]]
name = “counter_value_2”
oid = “.1.3.6.1” #( <— just an example ! )
#here in counter_value_2 I will have a numeric value : 120022202 (bytes)

I cannot write:

[[inputs.snmp.field]]
name = “${interface_name_2}”
#I would naming the field with the value got to the beginning “WAN_b”
oid = “.1.3.6.1”

I can do it statically or rename later…
maybe is not possible just using telegraf itself.

Thank you!

For collection interfaces and their name, you should look into using [[inputs.snmp.table]].

Thank you for your input,

Something like this:
[[inputs.snmp.table]]
name = “cpu_usage”
oid = “1.3.6.1.4.1.2021.10.1.5” # OID for CPU

[[inputs.snmp.table.field]]
name = “cpuIndex”
oid = “1.3.6.1.4.1.2021.10.1.1” # OID CPU’s index

[[inputs.snmp.table.field]]
name = “cpuLoad”
oid = “1.3.6.1.4.1.2021.10.1.5”

But I would get name of “cpuindex” dinamically from another OID,
how to achieve this?

Depends on how the relation of the other OID is. If it has the same index, then you can just add that as a new field in this table.

[[inputs.snmp.table.field]]
  name = “cpuName”
  oid = “1.3.6.1.something”
  is_tag = true

If you need to lookup the value of the index field, then you will need to look into processors.snmp_lookup.