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

Hi. I have an MQTT broker/server, mosquitto, running accepting inputs of temperature and tds/ec values for a hydroponics setup.

The data is collected and sent from the client (a NodeMCU device) and is received properly by the broker. I can verify that it is received correctly by querying the broker via the MQTT.fx tool.

I have a simple python script running on the same server as the broker that queries the values and then posts it to an InfluxDB. The DB receives that data and is the plotted out using Grafana. All’s good here.

I wanted to replace the python script with telegraf which I feel is a better way to do these instead of a bespoke script.

I set up the section in the telegraf.conf for inputs.mqtt_consumer as follows:
===== extracted from telegraph.conf =========
[inputs.mqtt_consumer]]
servers = [“tcp://127.0.0.1:1883”]
topics = [
“hydroponics/sensor/temperature”,
“hydroponics/sensor/tds”,
]
client_id = “telegraf”
======== end of extract =============
and when I run the following to test the config:

  • /usr/bin/telegraf --config /etc/telegraf/telegraf.conf --test

i get the following error:
2020-12-07T02:19:15Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:6: “29.38”
2020-12-07T02:19:15Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:7: “258.88”

I can’t see why there is an error based on the config above. All this while the python script is running just fine and adding to the Influx db.

Any hints/suggestions are most welcome.

Thanks.

Harish

Hello @harish,
Does this issue answer your question?

Thanks for the reply.

$ /usr/bin/telegraf --version
Telegraf 1.16.3 (git: HEAD c7f21728)

Changed to the following:
a) added data_type = “float”
b) changed data_format = “value” instead of data_format = “influx”

and re-ran the test (/usr/bin/telegraf --config /etc/telegraf/telegraf.conf --test) and it is now working.

Both the link and docs helped. Without the data_type setting, it fails so it is very critical.

Now I’ve “systemctl enable telegraf && systemctl start telegraf” and stopped running the python script.

Thank you very much.

Harish
PS: I’ll be adding all of these learnings to my blog post about the project at https://harishpillay.com/2020/12/01/my-esp8266-01-adventure/

1 Like