InfluxDB / Telegraf / MQTT - Can't read data

Hello All,
I send following JSON via MQTT:

With Topic: ‘PLT01/CTR01/UW2_PR_TotRMSVibVelo_1’

I can’t read those data on Telegraf in InfluxDB.
Below snippet from Telegraf configuration.

servers = [“tcp://”]

topics = [

data_format = “json”
tag_keys = [“WorkCenter” , “PlantCode” , “LineName” , “MachineName” , “SensorName”]

Telegraf Dubug shows some error:
[inputs.mqtt_consumer] Error in plugin: invalid character ‘\x00’ after top-level value

Who can help me? I spent lot of time trying to solve it and reading docu.


Hi @Tom999 - Welcome to the community forum.

Try Google search:
telegraf error in plugin invalid character ' ' after top-level value

This post talks about the same error message and this post is about the same setup (MQTT/Telegraf/InfluxDB). Also This Forum Post is about the same subject. All of these say something isn’t right (e.g., a bad format or unexpected character) in the JSON.

the problem is ‘\x00’ at the end of JSON payload. This is added on PLC level, where JSON message is created. I can’t manipulate it.
New idea would be to use JSON version 2 with parsing.

I tried this:
timestamp_path = “TimeStamp”
timestamp_format = “unix”

topic = “+/+/+”
tags = “WorkCenter/LineName/SensorName”

path = "AnalogValue"
type = "float"

path = "WorkCenter"

path = "PlantCode"

path = "LineName"

path = "MachineName"

path = "SensorName"

But now I get message “Invalid JSON provided, unable to parse”
How to configure Telegraf config file to use JSON ver 2 ?

No clear documentation is available.
I think my issue is very simple but there is no informative example how to handle it.

I have topic: ‘PLT01/CTR01/UW2_PR_TotRMSVibVelo_1’

And JSON payload:
‘{“TimeStamp”:1658602981983,“WorkCenter”:“PLIATDST12”,“PlantCode”:“2345”,“LineName”:“PLT01”,“MachineName”:“CTR01”,“SensorName”:“UW2_PR_TotRMSVibVelo_1”,“AnalogValue”:232.98875427246095}’ - last char is NULL.


Hi @Tom999 -
Detailed mqtt_consumer documentation can be found here.

There are some problems with this code.

  1. Do not mix [[inputs.mqtt_consumer]] and [[inputs.file]]. All lower-level plug-in statements must also start with [[inputs.mqtt . . .]].
  2. Lower-level statements must use proper indentation (see this recent post.)
  3. Need to specify data_format = "json_v2" at the beginning.
  4. First parse the topic to unwrap the payload, then parse the JSON. It is reversed in your code which probably caused the error message.