Telegraf default configuration for multiple mqtt_consumers

Is there a way to set once

[[inputs.mqtt_consumer]]
  servers = ["tcp://localhost:1883"]
  username = "user"
  password = "pass"
  connection_timeout = "30s"
  qos = 0
  # and other parameters when necessary

as defaults so that I wouldn’t need to repeat those in all different inputs? Usually this is the same basic configuration for most of the inputs.mqtt_consumers. Only changing part is the topics subscribed for the input and data_format, data_type, parsing and processing that varies depending on the topic.

Hi,

QOS defaults to 0 and connection_timeout to 30s as well, so you can exclude those entirely if you are not changing them.

The other three are unfortunately required.

You could go down the route of using environment variables to have them in one place, but that doesn’t remove the need to have them in your config.

1 Like