Telegraf error: [inputs.mqtt_consumer] Error in plugin: metric parse error:

Hi Everybody,

I’m using Telegraf with MQTT as an input plugin. MQTT is sending these kind of JSON messages:

Relevant parts of telegraf.conf:
servers = [“tcp://”]
topics = [ “Counters/#”,]
qos = 2
data_format = “json”

Telegraf cannot parse the input:
2021-12-21T19:09:42Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:42: “{“Count”:893409,“Momentary”:180011.250000,“Units”:40,“UnitsText”:“ltr”,“Period”:30,“PeriodText”:“hour”}”

JSON LINT finds no errors in my JSON messages…

I’ve been busting my head on this one for half a day now, anybody know what’s wrong?

You have to configure the json input:

JSON input data format | Telegraf 1.21 Documentation

Hi @Franky1 ,

Thanks for your quick reply!
I’ve been looking into that, but I don’t think that would eliminate the error(?)
What kind of configuration would you suggest I do to get rid of the error message?

Best regards,

I added this to the configuration:
data_format = “json”
tag_keys = [“Count”]
That got rid of the error. Not sure what it means though :slight_smile: but I intend to find out tomorrow…