Telegraf Error: configuration specified the fields ["measurement_name"], but they weren't used

2.1k Views Asked by At

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.

1

There are 1 best solutions below

0
On

I had a similar problem with my telgraf config:

[[inputs.http]]
  urls = ["http://relay.local/~mat/proxy_boiler.php"]
  data_format = "json"
  method = "GET"
  timeout = "5s"

[[inputs.http]]
  urls = ["http://relay.local/~mat/proxy_boiler.php?memory=true"]
  name = "memory"
  data_format = "json"
  method = "GET"
  timeout = "10s"

Which produced the error:

[telegraf] Error running agent: error loading config file /etc/telegraf/telegraf.conf: plugin inputs.http: line 22: configuration specified the fields ["name"], but they weren't used

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.