# Telegraf - ignoring measurement\_name

**URL:** <https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828>\
**Category:** Telegraf\
**Tags:** telegraf, json, parser\
**Created:** [October 4, 2022, 11:53am UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828 "2022-10-04T11:53:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirino](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mirino/32/11144_2.png) [@mirino](https://community.influxdata.com/u/mirino)\
**Post date:** [October 4, 2022, 11:53am UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/1 "2022-10-04T11:53:49Z")

</div>

Hello Experts,

I’m trying to change the measurement name, but I still can’t. I think that according to this manual I have everything OK. Don’t you know where the mistake could be?

[How to Parse JSON with Telegraf](https://www.influxdata.com/blog/how-parse-json-telegraf-influxdb-cloud/)

**telegraf.conf**

```auto
[[inputs.mqtt_consumer]]
    servers = ["tcp://192.168.2.16:1883"]
    topics = [
      "tele/+/STATE",
    ]
    data_format = "json_v2"
    [[inputs.mqtt_consumer.json_v2]]
        measurement_name = "zigbee"
        [[inputs.mqtt_consumer.json_v2.field]]
            path = "POWER"
            type = "string"
        [[inputs.mqtt_consumer.json_v2.field]]
            path = "UptimeSec"
            type = "int"
        [[inputs.mqtt_consumer.json_v2]]
        [[inputs.mqtt_consumer.json_v2.object]]
            path = "Wifi"
            included_keys = ["RSSI", "Signal"]

```

thank you for answer

Mirino

---

<div class="post-metadata">

**Author:** ![Giovanni\_Luisotto](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/giovanni_luisotto/32/4017_2.png) [@Giovanni\_Luisotto](https://community.influxdata.com/u/Giovanni_Luisotto)\
**Post date:** [October 4, 2022, 12:30pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/2 "2022-10-04T12:30:42Z")

</div>

Seems right to me, the only question is which version of telegraf are you using?  
I’ll have to look into it.

In the meanwhile you can use :  
[`name_override`](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#input-plugins) - Override the base name of the measurement. (Default is the name of the input).

put it at input level like this:

```auto
[[inputs.mqtt_consumer]]
  name_override = "zigbee"
  servers = ["tcp://192.168.2.16:1883"]
  {...}

```

---

<div class="post-metadata">

**Author:** ![mirino](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mirino/32/11144_2.png) [@mirino](https://community.influxdata.com/u/mirino)\
**Post date:** [October 4, 2022, 12:39pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/3 "2022-10-04T12:39:03Z")

</div>

```auto
ubuntu@raspberry1:~$ /usr/bin/telegraf --version
**Telegraf 1.24.1** (git: HEAD@bd7d53fb)

```

---

<div class="post-metadata">

**Author:** ![mirino](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mirino/32/11144_2.png) [@mirino](https://community.influxdata.com/u/mirino)\
**Post date:** [October 4, 2022, 5:12pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/4 "2022-10-04T17:12:23Z")

</div>

I just updateted to version Telegraf **1.24.2** (git: HEAD@9550e7a5) but same problem.

---

<div class="post-metadata">

**Author:** ![mirino](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mirino/32/11144_2.png) [@mirino](https://community.influxdata.com/u/mirino)\
**Post date:** [October 4, 2022, 5:21pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/5 "2022-10-04T17:21:40Z")

</div>

name\_override = “zigbee”  
That option works OK but all parsing fields go to one measurement “zigbee”

Now I will try to divide the fields  
“POWER” , “UptimeSec” → measurement “zigbee”  
“RSSI”, “Signal” → measurement\_name = “wifi”  
**but all fields go to one measurement “wifi” and ignoring “zigbee”**

```auto
[[inputs.mqtt_consumer]]
    servers = ["tcp://192.168.2.16:1883"]
    topics = [
      "tele/+/STATE",
    ]
    data_format = "json_v2"
    [[inputs.mqtt_consumer.json_v2]]
        measurement_name = "zigbee"
        [[inputs.mqtt_consumer.json_v2.field]]
            path = "POWER"
            type = "string"
        [[inputs.mqtt_consumer.json_v2.field]]
            path = "UptimeSec"
            type = "int"
        [[inputs.mqtt_consumer.json_v2]]
            measurement_name = "wifi"
        [[inputs.mqtt_consumer.json_v2.object]]
            path = "Wifi"
            included_keys = ["RSSI", "Signal"]

```

```auto

```

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [October 4, 2022, 8:43pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/6 "2022-10-04T20:43:35Z")

</div>

`measurement_name` cannot be redefined multiple times for a parser as you have above. Effectively what you want is to create 2 measurements. To do that means having the mqtt\_consumer read twice, one for each, or using the [starlark processor](https://github.com/influxdata/telegraf/tree/master/plugins/processors/starlark) to split the one metric into a second (e.g. [example](https://github.com/influxdata/telegraf/blob/master/plugins/processors/starlark/testdata/multiple_metrics.star) showing the creating of a second metric).

Another option is to have a single measurement with all this data:

```auto
zigbee,POWER="",Signal="" "UptimeSec"=VAL,RSSI=VAL

```

Or something similar to that rather than breaking them apart.

---

<div class="post-metadata">

**Author:** ![mirino](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mirino/32/11144_2.png) [@mirino](https://community.influxdata.com/u/mirino)\
**Post date:** [October 5, 2022, 12:15pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/7 "2022-10-05T12:15:53Z")

</div>

@jpowers I chose the option number 1 and everything works 🙂 , thx  
But I would also be interested in possibility number 2.([example](https://github.com/influxdata/telegraf/blob/master/plugins/processors/starlark/testdata/multiple_metrics.star)) Could you write it down for me in Starlank language?

```auto
[[inputs.mqtt_consumer]]
    servers = ["tcp://192.168.2.16:1883"]
    topics = [
      "tele/+/STATE",
    ]
    data_format = "json_v2"
    [[inputs.mqtt_consumer.json_v2]]
        measurement_name = "zigbee"
        [[inputs.mqtt_consumer.json_v2.field]]
            path = "POWER"
            type = "string"
        [[inputs.mqtt_consumer.json_v2.field]]
            path = "UptimeSec"
            type = "int"
[[inputs.mqtt_consumer]]
    servers = ["tcp://192.168.2.16:1883"]
    topics = [
      "tele/+/STATE",
    ]
    data_format = "json_v2"
    [[inputs.mqtt_consumer.json_v2]]
        measurement_name = "wifi"
        [[inputs.mqtt_consumer.json_v2.object]]
            path = "Wifi"
            included_keys = ["RSSI", "Signal"]

```

---

<div class="post-metadata">

**Author:** ![Giovanni\_Luisotto](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/giovanni_luisotto/32/4017_2.png) [@Giovanni\_Luisotto](https://community.influxdata.com/u/Giovanni_Luisotto)\
**Post date:** [October 5, 2022, 12:54pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/8 "2022-10-05T12:54:41Z")

</div>

You can also use standard processors to clone/split/edit your data, I’m thinking a mix of [metric filters](https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#metric-filtering) with the [processor.override](https://github.com/influxdata/telegraf/blob/master/plugins/processors/override/README.md). You should be able to get the existing point (clone it?), drop fields and change the measurement name.  
A clone is probably needed 8as there are 2 separate branches) but it’s pretty easy anyway as we got [processor.clone]

I’ve never used starlark so I’m not sure which way is easier

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [October 11, 2022, 7:05pm UTC](https://community.influxdata.com/t/telegraf-ignoring-measurement-name/26828/9 "2022-10-11T19:05:55Z")

</div>

@sspaink do you want to try to come up with a starlark script for this?
