Error in plugin: metric parse error: expected tag at "..."

Hey guys, im getting a error i cant fix. My telagraf shows the following error:

Aug 16 15:09:13 IOTRPI202 telegraf[5488]: 2021-08-16T14:09:13Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:7: "lunch, user=krebsnoe place=Dabei"

My config:

[[inputs.mqtt_consumer]]
  servers = ["tcp://127.0.0.1:1883"]
  topics = [ "lunch/#", ]
  data_format = "influx"

I tried data_typ string and data_format value but then grafana could not read the data anymore.

thx for your help

Hello @Eon_Sberk,
you can add a constant tag like so:

[[inputs.mqtt_consumer]]
  servers = ["tcp://127.0.0.1:1883"]
  topics = [ "lunch/#", ]
  data_format = "influx"
  [inputs.mqtt.tags]
     mytag = "mytagvalue"

You’ll also have to get rid of the space between fields as fields are comma separated.

To solve this type of problems I recommend using the --test flag when running your config to make sure that your output matches correct line protocol format.

Hello @Anaisdg,

Thank you for your fast answer!

Could you give me a example with my tags? Also for the seperation of the values because i could not figure it out.

Thanks :slight_smile:

@Eon_Sberk

You have influx configured as the input data_format, but I suspect the payload of the mqtt messages does not contain valid influx line protocol format.
Please post an example of your mqtt payload.

1 Like

I found out it works if i do:

lunch, user=krebsnoe place=1 but that dose not fix my Problem

Hello @Eon_Sberk,
Can you explain your mqtt payload further? What do you want to be tags and what do you want to be fields?
Can you might have to use a different input format like grok and then parse the output:

OR you could use the execd processor plugin.

@popey are there any quick fixes with the mqtt plugin that I’m not aware of?

Hello @Anaisdg

lunch is my topic, user and place are tag’s and krebsnoe and Dabei are the fields.

Im not sure if i understand Tags and Fields right so what i want would look like this in SQL:

INSERT INTO lunch(user, place) VALUES("krebsnoe", "Dabei"); 

I’m sorry, I don’t understand.
What works?
What is the problem?

I assume you have control over the mqtt payload? Then I would first create valid influx line protocol format as mqtt payload.

lunch, user=krebsnoe place=Dabei Dose not work and thats my Problem. In the end i just want to raed the place of each user

Yes, because it is not valid influx line protocol format.
See the format specification here:

https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/

This could be valid:

lunch,user=krebsnoe place="Dabei"

or

lunch,user=krebsnoe place=1u

Be aware that influx line protocol format is whitespace sensitive.

1 Like