influxdata / influxdata/telegraf
input.mqtt packet loss
Open
Nobody has claimed this yet.
bug
- Dominant language
- Go
- Stars
- 17.8k
- Forks
- 5.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 161
Description
Relevant telegraf.conf
## Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
alias = "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://xxxxx:1883"]
## Topics that will be subscribed to.
topics = [
#"company/country/site/device_type/device_id/Data",
"+/+/+/+/+/Data"
]
## 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 = 1
## 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 = 5000
## 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 = "collector"
## Username and password to connect MQTT server.
username = "xxx"
password = "xxx"
## Optional TLS Config
# tls_ca = "/etc/telegraf/certs/ca-bundle.crt"
# tls_cert = "/etc/telegraf/certs/client.crt"
# tls_key = "/etc/telegraf/certs/client.key"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
## Client trace messages
## When set to true, and debug mode enabled in the agent settings, the MQTT
## client's messages are included in telegraf logs. These messages are very
## noisey, but essential for debugging issues.
client_trace = false
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
[[inputs.internal]]
## If true, collect telegraf memory stats.
collect_memstats = true
[inputs.internal.tags]
host = "collector"
Logs from Telegraf
No errors detected in the logs, even activating traces.
System info
Telegraf 1.34.4, RHEL 7 + Docker
Docker
No response
Steps to reproduce
- Subscribe to several topics using wildcard. "+/+/+/+/+/Data"
- Subscribe to one unique topic. "company/country/site/device_type/device_id/Data"
- Compare result and verify that for several topics, even indicating QoS=1 there are packet loss.
Expected behavior
All the packets should be collected without any loss of data.
Actual behavior
Packet loss. Comparison of single vs multiple topics.
- Variable 1 collected by a mqtt.input telegraf config with single topic subscription.
- Variable 1 collected by a mqtt.input telegraf config with wilcard subscription.
- Variable 2 collected by a mqtt.input telegraf config with single topic subscription.
- Variable 2 collected by a mqtt.input telegraf config with wilcard subscription.
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the inputs.mqtt_consumer entry point and reproduce the comparison between the wildcard subscription "+/+/+/+/+/Data" and the single topic subscription. Use the provided Telegraf configuration and logs to investigate the reported packet loss; done means collecting the same packets without loss for both subscription patterns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- data-engineering
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100