Print all the topic name which telegraf forming a connection

I am using telegraf 1.22 for reading the data from the MQTT broker and it forms a connection with every topic.

MQTT broker getting restarted from some time the reason is telegraf forming much connection to MQTT broker and which is why MQTT is facing too much load from telegraf.

Now, I want to print all the topic names that are forming connections to the telegraf to exclude those I don’t require.

my telegraf configuration.

[[inputs.mqtt_consumer]]

  #servers = ["hostURL"]
  qos = 0
  topics = ["#"]

  ## The message topic will be stored in a tag specified by this value.  If set
  ## to the empty string no topic tag will be created.
  # topic_tag = "topic"

  ## QoS policy for messages
  ##   0 = at most once
  ##   1 = at least once
  ##   2 = exactly once
  ##
  ## When using a QoS of 1 or 2, you should enable persistent_session to allow
  ## resuming unacknowledged messages.
  # qos = 0

  ## Connection timeout for initial connection in seconds
  connection_timeout = "30s"

  ## Maximum messages to read from the broker that have not been written by an
  ## output.  For best throughput set based on the number of metrics within
  ## each message and the size of the output's metric_batch_size.
  ##
  ## For example, if each message from the queue contains 10 metrics and the
  ## output metric_batch_size is 1000, setting this to 100 will ensure that a
  ## full batch is collected and the write is triggered immediately without
  ## waiting until the next flush_interval.
  # max_undelivered_messages = 1000

  ## Persistent session disables clearing of the client session on connection.
  ## In order for this option to work you must also set client_id to identify
  ## the client.  To receive messages that arrived while the client is offline,
  ## also set the qos option to 1 or 2 and don't forget to also set the QoS when
  ## publishing.
  #   persistent_session = false

  ## If unset, a random client ID will be generated.
  client_id = "telegraf_oss"

  ## Username and password to connect MQTT server.
  username = "username"
  password = "password "


  name_override = "mqtt_data"

Thanks

Hi @Ravikant_Gautam,
Based on your current configuration you are subscribing to the route topic with a wild card. To check what topics are available within your broker I would consider using an MQTT Browser like:

actually, I don’t have permission to access to MQTT broker so I just got the username, password, and URL.
Now with the telegraf only I have to see which topics are available.

is there any way to do that?

The best current way to do it would be the following:

  1. Use the file output plugin: telegraf/plugins/outputs/file at master · influxdata/telegraf · GitHub
  2. Write some samples from the MQTT consumer to file using the output plugin.
  3. The tag called “topic” will contain the topics currently writing data.

The MQTT explorer should work if you have the username and password aswell as the URL. It acts like a client to explore the broker much like the Telegraf client does.