2016-02-09 22:03:46 +00:00
|
|
|
# MQTT Consumer Input Plugin
|
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
The [MQTT][mqtt] consumer plugin reads from the specified MQTT topics
|
|
|
|
and creates metrics using one of the supported [input data formats][].
|
2016-02-09 22:03:46 +00:00
|
|
|
|
|
|
|
### Configuration:
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[[inputs.mqtt_consumer]]
|
2017-10-30 22:33:20 +00:00
|
|
|
## MQTT broker URLs to be used. The format should be scheme://host:port,
|
|
|
|
## schema can be tcp, ssl, or ws.
|
|
|
|
servers = ["tcp://localhost:1883"]
|
2018-10-04 00:21:30 +00:00
|
|
|
|
|
|
|
## 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.
|
2016-02-09 22:03:46 +00:00
|
|
|
qos = 0
|
2018-10-04 00:21:30 +00:00
|
|
|
|
2017-09-11 19:24:51 +00:00
|
|
|
## Connection timeout for initial connection in seconds
|
2017-09-29 22:58:38 +00:00
|
|
|
connection_timeout = "30s"
|
2016-02-09 22:03:46 +00:00
|
|
|
|
2018-11-05 21:34:28 +00:00
|
|
|
## 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
|
|
|
|
|
2016-02-18 21:26:51 +00:00
|
|
|
## Topics to subscribe to
|
2016-02-09 22:03:46 +00:00
|
|
|
topics = [
|
|
|
|
"telegraf/host01/cpu",
|
|
|
|
"telegraf/+/mem",
|
|
|
|
"sensors/#",
|
|
|
|
]
|
|
|
|
|
2016-05-04 17:00:07 +00:00
|
|
|
# if true, messages that can't be delivered while the subscriber is offline
|
|
|
|
# will be delivered when it comes back (such as on service restart).
|
|
|
|
# NOTE: if true, client_id MUST be set
|
|
|
|
persistent_session = false
|
|
|
|
# If empty, a random client ID will be generated.
|
|
|
|
client_id = ""
|
2016-02-09 22:03:46 +00:00
|
|
|
|
2016-02-18 21:26:51 +00:00
|
|
|
## username and password to connect MQTT server.
|
2016-02-09 22:03:46 +00:00
|
|
|
# username = "telegraf"
|
|
|
|
# password = "metricsmetricsmetricsmetrics"
|
|
|
|
|
2018-05-04 23:33:23 +00:00
|
|
|
## 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
|
2016-02-09 22:03:46 +00:00
|
|
|
# insecure_skip_verify = false
|
|
|
|
|
2016-04-05 20:42:20 +00:00
|
|
|
## Data format to consume.
|
2017-04-27 21:59:18 +00:00
|
|
|
## Each data format has its own unique set of configuration options, read
|
2016-02-18 21:26:51 +00:00
|
|
|
## more about them here:
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
2016-02-09 22:03:46 +00:00
|
|
|
data_format = "influx"
|
|
|
|
```
|
|
|
|
|
|
|
|
### Tags:
|
|
|
|
|
|
|
|
- All measurements are tagged with the incoming topic, ie
|
|
|
|
`topic=telegraf/host01/cpu`
|
2018-11-05 21:34:28 +00:00
|
|
|
|
|
|
|
[mqtt]: https://mqtt.org
|
|
|
|
[input data formats]: /docs/DATA_FORMATS_INPUT.md
|