Trying to use simplest possible telegraf consumer config pointing to public broker and yet i get this "error listening for Data". Please help!

Hi,

Where are you running Telegraf? Could you provide the logs from Telegraf?

Thanks!

it feels like i am missing something but i am trying to use open mqtt broker so no logs unfortunately. Here is the mqtt consumer config part of telegraf config


[[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://mqtt.fluux.io:1883”]

Topics that will be subscribed to.

topics = [
“telegraf/host01/cpu”,
“telegraf/+/mem”,
“sensors/#”,
]

topic_fields = “//_/temperature”

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 = “”

Username and password to connect MQTT server.

username = “telegraf”

password = “metricsmetricsmetricsmetrics”

Optional TLS Config

tls_ca = “/etc/telegraf/ca.pem”

tls_cert = “/etc/telegraf/cert.pem”

tls_key = “/etc/telegraf/key.pem”

Use TLS but skip chain & host verification

insecure_skip_verify = false

Data format to consume.

Each data format has its own unique set of configuration options, read

more about them here:

telegraf/DATA_FORMATS_INPUT.md at master · influxdata/telegraf · GitHub

data_format = “influx”

Enable extracting tag values from MQTT topics

_ denotes an ignored entry in the topic path

[[inputs.mqtt_consumer.topic_parsing]]

topic = “”

measurement = “”

tags = “”

fields = “”

[inputs.mqtt_consumer.topic_parsing.types]

Right, so you just pasted the Telegraf configuration. Where are you running Telegraf? InfuxDB Cloud does not run Telegraf for you, you still have to run it somewhere so that the flow is:

mqtt broker <-- telegraf --> influxdb cloud

so, its all the comments. w/o comments its these 5 rows only . But what do i do if i want to run cloud only? cloud public broker?

[[inputs.mqtt_consumer]]

servers = [“tcp://mqtt.fluux.io:1883”]
topics = [
“telegraf/host01/cpu”,
“telegraf/+/mem”,
“sensors/#”,
]
data_format = “influx”

If you want everything in the cloud, then you could set up a cloud instance to run telegraf on with the config you have. You would need to ensure it could reach both the mqtt consumer as well as influxdb cloud.

Thanks, i understand that now. Unfortunately setting up a cloud instance makes it non-maintenance-free so i start to think of doing rest calls towards influx due to performance wise it seems ok. Next challenge is understand how to make influx-compatible raw data. Any examples e.g. of influx compatible json would be much appreciated.