I have configured Telegraf to collect from an mqtt queue, but it is not working and I can't see the reason why.
The error
2022-11-15T19:30:13Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: plugin inputs.mqtt_consumer: line 128: configuration specified the fields ["measurement_name"], but they weren't used
The relevant config
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb_v2]]
urls = ["<removed>.aws.cloud2.influxdata.com"]
bucket = "ems-esp"
token = "<removed>"
organization = "<removed>"
# Below is line 128 where the error occurs
[[inputs.mqtt_consumer]]
## Broker URLs for the MQTT server or cluster. To connect to multiple
## clusters or standalone servers, use a separate plugin instance.
## example: servers = ["tcp://localhost:1883"]
## servers = ["ssl://localhost:1883"]
## servers = ["ws://localhost:1883"]
servers = ["tcp://192.168.178.61:1883"]
topics = [
"ems-esp/boiler_data_ww",
"ems-esp/boiler_data",
"ems-esp/thermostat_data",
"ems-esp/thermostat_data_hc1",
"ems-esp/solar_data",
"ems-esp/heartbeat",
"ems-esp/info",
]
data_format = "json"
[[inputs.mqtt_consumer]]
servers = ["tcp://192.168.178.61:1883"]
topics = [
"shellies/ht_lounge/info"
]
data_format = "json"
But the line it points to is just the definition [[inputs.mqtt_consumer]]
and I don't see the problem. Nor can I find anything else in the file that is incorrect.
I had a similar problem with my telgraf config:
Which produced the error:
Line 22 pointed to the first instance of the inputs.http but the actual problem was on line 32 with the name = "memory". I believe this has been depreciated in a recent version of Telegraf so removing that line allows Telegraf to run.
Try searching for "measurement_name" in your code and removing it.