Hello there,
i really need some support to get telegraf communication from mqtt to influxDB up and running.
Here is my setup:
im sending json format to my mqtt broker. There are several topic like DHT22/livingroom, DHT22/bedroom and so on. The json-string looks like this:
{"temperature":21.20000076,"humidity":62.59999847}
Im trying to fetch those messages with telegraf and write them to influxDB.
Here is my telegraf.conf:
[global_tags]
[agent]
interval = "60s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = "192.xxx.0.xxx"
omit_hostname = false
## Log at debug level.
debug = true
## Log only error level messages.
quiet = false
[[outputs.influxdb]]
urls = ["http://influxdb:8086"]
database = "influx"
timeout = "5s"
username = "telegraf"
password = "***"
# Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
servers = ["tcp://192.168.178.67:1883"]
## Topics that will be subscribed to.
topics = [
"DHT22/#",
]
data_format ="json_v2"
[[inputs.mqtt_consumer.topic_parsing]]
topic = "DHT22/+"
measurement = "measurement/_"
tags = "_/room"
[[inputs.mqtt_consumer.json_v2]]
[[inputs.mqtt_consumer.json_v2.tag]]
path = "humidity"
type = "float"
[[inputs.mqtt_consumer.json_v2.field]]
path = "temperature"
type = "float"
Telegraf seems to connect to influxDB and the mqtt-broker without any issues. But im not seeing any messages arriving at telegraf. See logfile:
2023-10-28T10:02:43Z I! Loading config: /etc/telegraf/telegraf.conf
2023-10-28T10:02:43Z I! Starting Telegraf 1.28.3 brought to you by InfluxData the makers of InfluxDB
2023-10-28T10:02:43Z I! Available plugins: 240 inputs, 9 aggregators, 29 processors, 24 parsers, 59 outputs, 5 secret-stores
2023-10-28T10:02:43Z I! Loaded inputs: mqtt_consumer
2023-10-28T10:02:43Z I! Loaded aggregators:
2023-10-28T10:02:43Z I! Loaded processors:
2023-10-28T10:02:43Z I! Loaded secretstores:
2023-10-28T10:02:43Z I! Loaded outputs: influxdb
2023-10-28T10:02:43Z I! Tags enabled: host=192.xxx.0.xxx
2023-10-28T10:02:43Z I! [agent] Config: Interval:1m0s, Quiet:false, Hostname:"192.xxx.0.xxx", Flush Interval:10s
2023-10-28T10:02:43Z D! [agent] Initializing plugins
2023-10-28T10:02:43Z D! [agent] Connecting outputs
2023-10-28T10:02:43Z D! [agent] Attempting connection to [outputs.influxdb]
2023-10-28T10:02:44Z D! [agent] Successfully connected to outputs.influxdb
2023-10-28T10:02:44Z D! [agent] Starting service inputs
2023-10-28T10:02:44Z I! [inputs.mqtt_consumer] Connected [tcp://192.168.178.67:1883]
2023-10-28T10:02:54Z D! [outputs.influxdb] Wrote batch of 1 metrics in 6.27725ms
2023-10-28T10:02:54Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2023-10-28T10:03:04Z D! [outputs.influxdb] Wrote batch of 1 metrics in 6.193942ms
2023-10-28T10:03:04Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2023-10-28T10:03:14Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2023-10-28T10:03:24Z D! [outputs.influxdb] Wrote batch of 1 metrics in 5.639901ms
2023-10-28T10:03:24Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
I guess its some case of bad telgraf.conf but i wasnt able to figure it out, hopefully some of you could support me.