# Rename dinamically

**URL:** <https://community.influxdata.com/t/rename-dinamically/49290>\
**Category:** Telegraf\
**Created:** [January 3, 2025, 6:26pm UTC](https://community.influxdata.com/t/rename-dinamically/49290 "2025-01-03T18:26:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tinyG](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tinyG](https://community.influxdata.com/u/tinyG)\
**Post date:** [January 3, 2025, 6:26pm UTC](https://community.influxdata.com/t/rename-dinamically/49290/1 "2025-01-03T18:26:53Z")

</div>

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 🙂  
temperature |33  
temperature\_ext|22

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [January 3, 2025, 7:32pm UTC](https://community.influxdata.com/t/rename-dinamically/49290/2 "2025-01-03T19:32:15Z")

</div>

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

> <https://github.com/influxdata/telegraf/blob/master/plugins/processors/converter/README.md>

> <https://github.com/influxdata/telegraf/blob/master/plugins/processors/rename/README.md>

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [January 3, 2025, 7:35pm UTC](https://community.influxdata.com/t/rename-dinamically/49290/3 "2025-01-03T19:35:23Z")

</div>

Or maybe just rename actually.

```auto
# 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?

> <https://github.com/influxdata/telegraf/blob/master/plugins/processors/rename/README.md>

---

<div class="post-metadata">

**Author:** ![tinyG](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tinyG](https://community.influxdata.com/u/tinyG)\
**Post date:** [January 4, 2025, 10:51am UTC](https://community.influxdata.com/t/rename-dinamically/49290/4 "2025-01-04T10:51:40Z")

</div>

Thank you for replies,  
I tried to check [telegraf/docs/CONFIGURATION.md at master · influxdata/telegraf · GitHub](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md)  
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!

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [January 21, 2025, 11:48am UTC](https://community.influxdata.com/t/rename-dinamically/49290/5 "2025-01-21T11:48:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tinyG](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@tinyG](https://community.influxdata.com/u/tinyG)\
**Post date:** [January 21, 2025, 1:20pm UTC](https://community.influxdata.com/t/rename-dinamically/49290/6 "2025-01-21T13:20:01Z")

</div>

Thank you for your input,

> [@Hipska](#):
>
> [[inputs.snmp.table]]

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?

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [January 21, 2025, 3:16pm UTC](https://community.influxdata.com/t/rename-dinamically/49290/7 "2025-01-21T15:16:21Z")

</div>

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.

```toml
[[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`.
