[[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://192.168.1.250:1883”]
Topics that will be subscribed to.
topics = [
“wenshidu.test”,
]
qos = 0
Connection timeout for initial connection in seconds
connection_timeout = “30s”
Username and password to connect MQTT server.
username = “admin”
password = “88888888”
data_format = “influx”
[[inputs.mqtt_consumer.topic_parsing]]
topic = “/+/+/+/+/+/+/+/” # all topics with 9 segments
measurement = “//c1/temp/////"
tags = "//c1//////"
fields = "///temp/////_”
#[inputs.mqtt_consumer.topic_parsing.types]
#temp = “float”
Format of information sent by sensor
A003W37251330001,00-00-00-00-00,C1,020.0,N,C2,043.8,N,0D0A
======================================================================
DEBUG
root@flow-monitor:/etc/telegraf# telegraf --debug
2022-04-18T15:32:45Z I! Using config file: /etc/telegraf/telegraf.conf
2022-04-18T15:32:45Z I! Starting Telegraf 1.22.1
2022-04-18T15:32:45Z I! Loaded inputs: cpu disk diskio mem mqtt_consumer net system
2022-04-18T15:32:45Z I! Loaded aggregators:
2022-04-18T15:32:45Z I! Loaded processors:
2022-04-18T15:32:45Z I! Loaded outputs: influxdb prometheus_client
2022-04-18T15:32:45Z I! Tags enabled: host=flow-monitor
2022-04-18T15:32:45Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:“flow-monitor”, Flush Interval:10s
2022-04-18T15:32:45Z D! [agent] Initializing plugins
2022-04-18T15:32:45Z D! [agent] Connecting outputs
2022-04-18T15:32:45Z D! [agent] Attempting connection to [outputs.influxdb]
2022-04-18T15:32:45Z D! [agent] Successfully connected to outputs.influxdb
2022-04-18T15:32:45Z D! [agent] Attempting connection to [outputs.prometheus_client]
2022-04-18T15:32:45Z I! [outputs.prometheus_client] Listening on http://[::]:9273/metrics
2022-04-18T15:32:45Z D! [agent] Successfully connected to outputs.prometheus_client
2022-04-18T15:32:45Z D! [agent] Starting service inputs
2022-04-18T15:32:45Z I! [inputs.mqtt_consumer] Connected [tcp://192.168.1.250:1883]
2022-04-18T15:32:53Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:32: “A003W37251330001,00-00-00-00-00,C1,020.1,N,C2,043.4,N,0D0A”
2022-04-18T15:32:55Z D! [outputs.prometheus_client] Wrote batch of 19 metrics in 1.428374ms
2022-04-18T15:32:55Z D! [outputs.prometheus_client] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:32:55Z D! [outputs.influxdb] Wrote batch of 19 metrics in 86.24306ms
2022-04-18T15:32:55Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:33:05Z D! [outputs.prometheus_client] Wrote batch of 24 metrics in 3.925888ms
2022-04-18T15:33:05Z D! [outputs.prometheus_client] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:33:05Z D! [outputs.influxdb] Wrote batch of 24 metrics in 88.026197ms
2022-04-18T15:33:05Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:33:15Z D! [outputs.prometheus_client] Wrote batch of 24 metrics in 1.51676ms
2022-04-18T15:33:15Z D! [outputs.prometheus_client] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:33:15Z D! [outputs.influxdb] Wrote batch of 24 metrics in 89.030155ms
2022-04-18T15:33:15Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:33:23Z E! [inputs.mqtt_consumer] Error in plugin: metric parse error: expected tag at 1:32: “A003W37251330001,00-00-00-00-00,C1,020.1,N,C2,043.4,N,0D0A”
2022-04-18T15:33:25Z D! [outputs.prometheus_client] Wrote batch of 24 metrics in 1.287387ms
2022-04-18T15:33:25Z D! [outputs.prometheus_client] Buffer fullness: 0 / 10000 metrics
2022-04-18T15:33:25Z D! [outputs.influxdb] Wrote batch of 24 metrics in 90.790985ms
2022-04-18T15:33:25Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics