# Ignore Sub Topic in MQTT input in telegraf

**URL:** <https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452>\
**Category:** Telegraf\
**Tags:** mqtt\
**Created:** [June 26, 2023, 12:22pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452 "2023-06-26T12:22:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [June 26, 2023, 12:22pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/1 "2023-06-26T12:22:39Z")

</div>

Hello,

I’ve a question, I’m running Telegraf Version 1.27.1.  
On that I got a input mqtt\_consumer configured with data\_format = value and data\_type = float.

The topic and subtopic I’m parsing is full of numeric values except two. Can I exclude them so that they won’t get processed?  
Right now I’m experiencing that Telegraf will stop at all after an amount of time because it’s complaining that:

E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax

When I restart telegraf it will continue to work.

So I tried with topic\_parsing and other things I found on the net but didn’t get it working.  
That “offline” part is one of the subtopics which is indeed string. See the below screenshot of the structure.

 ![Bildschirmfoto 2023-06-26 um 14.06.09](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/6/617e566a3cb2088f5675c6330312d35caa2afe8b.png)

Can someone give me a hint how to configure the input correctly and parsing the status part or ignoring it?

Thanks!

---

<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:** [June 27, 2023, 4:45pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/2 "2023-06-27T16:45:29Z")

</div>

> [@fork](#):
>
> I’m experiencing that Telegraf will stop at all after an amount of time

I didn’t expect telegraf to stop due to an error during parsing. Are you certain there isn’t another error?

---

<div class="post-metadata">

**Author:** ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)\
**Post date:** [June 28, 2023, 11:55am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/3 "2023-06-28T11:55:17Z")

</div>

@fork can you please try the binary in [feat(parsers.value): Add support for automatic fallback for numeric types by srebhan · Pull Request #13506 · influxdata/telegraf · GitHub](https://github.com/influxdata/telegraf/pull/13506) with `data_type = "auto_float"` and let me know if this works for you!? This new setting allows to fallback to a string if the value in the topic is not a floating-point value…

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [June 30, 2023, 9:24am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/4 "2023-06-30T09:24:14Z")

</div>

Yes it will stop to process. For testing I separated the mqtt input topic with the string float mix from the others and only that is not processing anymore. Here is the the log taken right now:

> 2023-06-23T21:45:57Z I! Loading config: /etc/telegraf/telegraf.conf  
> 2023-06-23T21:45:57Z I! Starting Telegraf 1.27.1  
> 2023-06-23T21:45:57Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores  
> 2023-06-23T21:45:57Z I! Loaded inputs: mqtt\_consumer (2x)  
> 2023-06-23T21:45:57Z I! Loaded aggregators:  
> 2023-06-23T21:45:57Z I! Loaded processors:  
> 2023-06-23T21:45:57Z I! Loaded secretstores:  
> 2023-06-23T21:45:57Z I! Loaded outputs: influxdb\_v2  
> 2023-06-23T21:45:57Z I! Tags enabled: host=telegrafProx  
> 2023-06-23T21:45:57Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:“telegrafProx”, Flush Interval:10s  
> 2023-06-23T21:45:57Z I! [inputs.mqtt\_consumer] Connected [tcp://mqtt:1883]  
> 2023-06-23T21:45:57Z I! [inputs.mqtt\_consumer] Connected [tcp://mqtt:1883]  
> 2023-06-23T21:45:57Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “online”: invalid syntax  
> 2023-06-23T21:45:57Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “online”: invalid syntax  
> 2023-06-23T21:46:02Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:46:20Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:46:32Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:46:50Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:47:02Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:47:20Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:47:32Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:47:50Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:48:02Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:48:20Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:48:32Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:48:50Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-23T21:49:02Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> …CUT…  
> 2023-06-24T01:54:32Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-24T01:54:50Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-24T01:55:02Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax  
> 2023-06-24T01:55:20Z E! [inputs.mqtt\_consumer] Error in plugin: strconv.ParseFloat: parsing “offline”: invalid syntax

These were the last lines. As you can the the input processing stopped at the 24th. And as of today it’s the 30th.  
The other inputs in the configuration (also mqtt) are still working without an error.

---

<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:** [June 30, 2023, 7:18pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/5 "2023-06-30T19:18:13Z")

</div>

@fork,

We’ve had another user who is using the mqtt\_consumer plugin, who also gets parsing errors also run into the plugin stop collecting data. Can you try the artifact in [fix(inputs.mqtt\_consumer): add client debug by powersj · Pull Request #13478 · influxdata/telegraf · GitHub](https://github.com/influxdata/telegraf/pull/13478) and provide the logs?

Thanks

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [July 6, 2023, 1:33pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/6 "2023-07-06T13:33:11Z")

</div>

Hi sorry for the late reply.  
Can you provide or update the repo with a Dockerfile so that I can build a image for testing?  
I’ve checked the makefile, there is a

> docker-image

directive with points to

> scripts/buster.docker

but that Dockerfile doesn’t exists in the folder.

I already build the versions but I like to swap the container on my hosting server which runs atm the official telegraf image. And because there must be a Dockerfile somewhere, maybe you can provide it before I’ve to write my own 🙂

---

<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:** [July 6, 2023, 1:41pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/7 "2023-07-06T13:41:55Z")

</div>

> [@fork](#):
>
> Can you provide or update the repo with a Dockerfile so that I can build a image for testing?

We do not provide or build Docker images for every PR, that would be a lot 😉

The [official docker images](https://github.com/influxdata/influxdata-docker) use Telegraf from a repo, so that won’t be much use to you. What I do locally is use a Dockerfile like this when I want to take a local build and try it out:

```auto
FROM archlinux 

COPY telegraf /usr/bin/telegraf

CMD ["/usr/bin/telegraf"]

```

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [July 12, 2023, 2:54pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/8 "2023-07-12T14:54:35Z")

</div>

Hey I saw that both PRs are merged into master and a new version is released.  
I don’t know if your client debug part is in master but now I got this, when things stop working:

```auto
2023-07-12T11:36:26Z I! Loading config: /etc/telegraf/telegraf.conf
2023-07-12T11:36:26Z I! Starting Telegraf 1.27.2
2023-07-12T11:36:26Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores
2023-07-12T11:36:26Z I! Loaded inputs: mqtt_consumer (2x)
2023-07-12T11:36:26Z I! Loaded aggregators:
2023-07-12T11:36:26Z I! Loaded processors:
2023-07-12T11:36:26Z I! Loaded secretstores:
2023-07-12T11:36:26Z I! Loaded outputs: influxdb_v2
2023-07-12T11:36:26Z I! Tags enabled: host=telegrafProx
2023-07-12T11:36:26Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"telegrafProx", Flush Interval:10s
2023-07-12T11:36:26Z I! [inputs.mqtt_consumer] Connected [tcp://mqtt:1883]
2023-07-12T11:36:26Z I! [inputs.mqtt_consumer] Connected [tcp://mqtt:1883]
2023-07-12T11:49:41Z E! [inputs.mqtt_consumer] could not mark message delivered: 2718
2023-07-12T12:34:13Z E! [inputs.mqtt_consumer] could not mark message delivered: 11788
2023-07-12T13:21:14Z E! [inputs.mqtt_consumer] could not mark message delivered: 21324
2023-07-12T14:32:14Z E! [inputs.mqtt_consumer] could not mark message delivered: 35809

```

So what’s next to do? Increase debug level somewhere?

---

<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:** [July 12, 2023, 2:57pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/9 "2023-07-12T14:57:39Z")

</div>

> [@fork](#):
>
> `could not mark message delivered`

The question is: why can it not mark messages as delivered? Is networking blocked in that direction?

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [July 12, 2023, 3:02pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/10 "2023-07-12T15:02:25Z")

</div>

I can’t tell you.  
Both Hosts are on same subnet without firewall. Nothing blocked and no evidence of something wrong on mosquitto mqtt side.

---

<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:** [July 12, 2023, 3:59pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/11 "2023-07-12T15:59:29Z")

</div>

Does your mosquitto logs show that it is communicating back?

If you get into the telegraf container itself can you communicate or connect to the mosquitto server.

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [July 13, 2023, 11:24am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/12 "2023-07-13T11:24:21Z")

</div>

So I checked to logs on mosquitto side. I saw the telegraf connect and no disconnect so far.

Also I tried to connect to the server from the container via shell, and mosquitto is logging it.  
So it seems not an network issue. The mosquitto server is also running for more than 2 years very stable without any issues.

---

<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:** [July 13, 2023, 1:02pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/13 "2023-07-13T13:02:14Z")

</div>

> [@fork](#):
>
> Telegraf Version 1.27.1

Can you update to 1.27.2 we did include a fairy large mqtt fix with that version

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [July 13, 2023, 7:53pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/14 "2023-07-13T19:53:46Z")

</div>

> [@fork](#):
>
> ```auto
> 2023-07-12T11:36:26Z I! Loading config: /etc/telegraf/telegraf.conf
> 2023-07-12T11:36:26Z I! Starting Telegraf 1.27.2
> 2023-07-12T11:36:26Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores
> 2023-07-12T11:36:26Z I! Loaded inputs: mqtt_consumer (2x)
> 2023-07-12T11:36:26Z I! Loaded aggregators:
> 2023-07-12T11:36:26Z I! Loaded processors:
> 2023-07-12T11:36:26Z I! Loaded secretstores:
> 2023-07-12T11:36:26Z I! Loaded outputs: influxdb_v2
> 2023-07-12T11:36:26Z I! Tags enabled: host=telegrafProx
> 2023-07-12T11:36:26Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"telegrafProx", Flush Interval:10s
> 2023-07-12T11:36:26Z I! [inputs.mqtt_consumer] Connected [tcp://mqtt:1883]
> 2023-07-12T11:36:26Z I! [inputs.mqtt_consumer] Connected [tcp://mqtt:1883]
> 2023-07-12T11:49:41Z E! [inputs.mqtt_consumer] could not mark message delivered: 2718
> 2023-07-12T12:34:13Z E! [inputs.mqtt_consumer] could not mark message delivered: 11788
> 2023-07-12T13:21:14Z E! [inputs.mqtt_consumer] could not mark message delivered: 21324
> 2023-07-12T14:32:14Z E! [inputs.mqtt_consumer] could not mark message delivered: 35809
> 
> ```

It’s already 1.27.2  
And the number just increased since then. Maybe you can put a debug option in it, so that I can switch it on?

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [August 31, 2023, 11:41am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/15 "2023-08-31T11:41:58Z")

</div>

So found out about the debug options you included with  
[agent]  
debug = on

and in the MQTT section. In the meantime we are at 1.27.4 and it’s working without issues! So something had been fixed!  
Thanks for your effort @jpowers !

@srebhan I tried your auto\_float implementation. Sadly it is not writing any values with that. Any Ideas how to track that down? I can also open an Issue at GitHub if you want.

---

<div class="post-metadata">

**Author:** ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)\
**Post date:** [September 6, 2023, 10:33am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/16 "2023-09-06T10:33:14Z")

</div>

@fork can you please post your (redacted) config for the `mqtt_consumer` input!? I suspect your topic layout is still the same?

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [September 7, 2023, 11:56am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/17 "2023-09-07T11:56:26Z")

</div>

Hey @srebhan ofc.

Layout is still the same. All fields are float except two string fields: “status” and “logger\_status”.

```auto
[[inputs.mqtt_consumer]]
  servers = ["tcp://mqtt:1883"]
  topics = [
    "WrGiebel/#",
  ]
  topic_tag = "topic"
  client_trace = true
  client_id = "telegrafWr"
  username = "telegraf"
  password = "XXXX"
  insecure_skip_verify = false
  data_format = "value"
  data_type = "auto_float"

```

---

<div class="post-metadata">

**Author:** ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)\
**Post date:** [September 12, 2023, 9:33am UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/18 "2023-09-12T09:33:37Z")

</div>

@fork are you aware that `data_type = "auto_float"` only works since 1.28.0 released yesterday!? Or are you using a nightly build?

---

<div class="post-metadata">

**Author:** ![fork](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/fork/32/13726_2.png) [@fork](https://community.influxdata.com/u/fork)\
**Post date:** [September 13, 2023, 3:20pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/19 "2023-09-13T15:20:13Z")

</div>

Hey @srebhan you are absolutely correct I was not using 1.28.0 and were not aware of that it was just released in 1.28.0.  
But since I didn’t get any warnings or error messages when I hat it configured in \<1.28.0 I was at a state that it was implemented in the version.

tl;dr, Works now but one of my Datapoints seems to be float already and auto\_float seems to try to put it in as string and Influx is throwing an error now because of that.  
Had to figure that out…

---

<div class="post-metadata">

**Author:** ![srebhan](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/srebhan/32/8572_2.png) [@srebhan](https://community.influxdata.com/u/srebhan)\
**Post date:** [September 18, 2023, 1:19pm UTC](https://community.influxdata.com/t/ignore-sub-topic-in-mqtt-input-in-telegraf/30452/20 "2023-09-18T13:19:58Z")

</div>

Yeah the issue is that I checked the value only with the new feature. Before it just silently ignored all mistypes `data_type` values… ☹

For the column type being already float: There is nothing we can do about it as InfluxDB only accepts one data-type per field in a series.
