influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.59k stars 5.56k forks source link

Improve error messages if wildcard topic is invalid in mqtt_consumer input #4437

Closed daanzu closed 6 years ago

daanzu commented 6 years ago

Relevant telegraf.conf:

[[inputs.mqtt_consumer]]
  servers = ["tcp://192.168.1.253:1883"]
  qos = 0
  connection_timeout = "30s"
  topics = [
    "foo/#/baz",
  ]
  persistent_session = false
  client_id = ""
  data_format = "value"
  data_type = "float"

System info:

Telegraf tested on windows and linux/raspbian, and last 4 minor versions. Mosquitto MQTT broker.

Steps to reproduce:

  1. Run telegraf with mqtt_consumer subscribing to a topic with wildcard

Expected behavior:

Receive messages.

Actual behavior:

No received messages, constant connects/disconnects/errors, and no clear clue to the root cause. Especially frustrating since the docs give wildcard topics as an example!

Additional info:

Example log:

2018-07-18T08:08:12Z I! MQTT Client Connected
2018-07-18T08:08:20Z E! Error in plugin [inputs.mqtt_consumer]: E! MQTT Connection lost
error: EOF
MQTT Client will try to reconnect
2018-07-18T08:08:20Z I! MQTT Client Connected
2018-07-18T08:08:20Z I! MQTT Client Connected
2018-07-18T08:08:30Z D! MQTT Consumer, connection error - Network Error : %!s(<nil>)

Errors repeat continuously.

Subscribing to "foo/bar/baz" works fine.

daanzu commented 6 years ago

My bad; it turns out I was attempting to subscribe to non-standard topic wildcard constructions. Nevertheless, it'd be nice to get a more helpful error message somehow.

danielnelson commented 6 years ago

Reopening so that we can investigate improving the log message.

danielnelson commented 6 years ago

I looked into showing a better log message here but we are already logging errors from the subscription. I don't think we will be able to improve the error reporting on this issue.