Hi,
I am trying to get values from mqtt to telegraf. However, some fields are always missing, especially the fields
U_DC
and P_DC
What’s the trick here?
root@raspberrypi:~# cat /root/telegraf-mqtt.conf
[global_tags]
[agent]
interval = "1s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
hostname = ""
omit_hostname = false
# logfile = "/var/log/telegraf/telegraf.log"
debug = true
# Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
servers = ["tcp://127.0.0.1:1883"]
topics = [
"ahoy/+/+/+"
]
qos = 0
connection_timeout = "30s"
username = ""
password = ""
data_format = "value"
data_type = "float"
root@raspberrypi:~# telegraf --config /root/telegraf-mqtt.conf --test
2023-08-04T14:53:16Z I! Loading config: /root/telegraf-mqtt.conf
2023-08-04T14:53:16Z I! Starting Telegraf 1.27.1
2023-08-04T14:53:16Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores
2023-08-04T14:53:16Z I! Loaded inputs: mqtt_consumer
2023-08-04T14:53:16Z I! Loaded aggregators:
2023-08-04T14:53:16Z I! Loaded processors:
2023-08-04T14:53:16Z I! Loaded secretstores:
2023-08-04T14:53:16Z W! Outputs are not used in testing mode!
2023-08-04T14:53:16Z I! Tags enabled: host=raspberrypi
2023-08-04T14:53:16Z D! [agent] Initializing plugins
2023-08-04T14:53:16Z D! [agent] Starting service inputs
2023-08-04T14:53:16Z I! [inputs.mqtt_consumer] Connected [tcp://127.0.0.1:1883]
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch1/YieldDay value=0 1691160796338518044
2023-08-04T14:53:16Z D! [agent] Stopping service inputs
2023-08-04T14:53:16Z D! [inputs.mqtt_consumer] Disconnecting [tcp://127.0.0.1:1883]
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch1/YieldTotal value=46.065 1691160796365842142
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch2/YieldDay value=0 1691160796366287128
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch2/YieldTotal value=26.298 1691160796366682115
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch0/YieldDay value=2170 1691160796373827879
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch0/YieldTotal value=45.98 1691160796376226800
2023-08-04T14:53:16Z D! [inputs.mqtt_consumer] Disconnected [tcp://127.0.0.1:1883]
2023-08-04T14:53:16Z D! [agent] Input channel closed
2023-08-04T14:53:16Z D! [agent] Stopped Successfully
Here is the full output from mqtt explorer. As I am very new to mosquitto, I do not know how to do that via cli:
Thanks and kind regards!
EDIT: adding the fields explicitly also does not take any effect:
root@raspberrypi:~# cat /root/telegraf-mqtt.conf
[global_tags]
[agent]
interval = "1s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = "0s"
hostname = ""
omit_hostname = false
# logfile = "/var/log/telegraf/telegraf.log"
debug = true
# Read metrics from MQTT topic(s)
[[inputs.mqtt_consumer]]
servers = ["tcp://127.0.0.1:1883"]
topics = [
"ahoy/+/+/U_DC",
"ahoy/+/+/YieldDay",
"ahoy/+/+/I_DC"
]
qos = 0
connection_timeout = "30s"
username = ""
password = ""
data_format = "value"
data_type = "float"
root@raspberrypi:~# telegraf --config /root/telegraf-mqtt.conf --test
2023-08-04T14:59:36Z I! Loading config: /root/telegraf-mqtt.conf
2023-08-04T14:59:36Z I! Starting Telegraf 1.27.1
2023-08-04T14:59:36Z I! Available plugins: 237 inputs, 9 aggregators, 28 processors, 23 parsers, 59 outputs, 4 secret-stores
2023-08-04T14:59:36Z I! Loaded inputs: mqtt_consumer
2023-08-04T14:59:36Z I! Loaded aggregators:
2023-08-04T14:59:36Z I! Loaded processors:
2023-08-04T14:59:36Z I! Loaded secretstores:
2023-08-04T14:59:36Z W! Outputs are not used in testing mode!
2023-08-04T14:59:36Z I! Tags enabled: host=raspberrypi
2023-08-04T14:59:36Z D! [agent] Initializing plugins
2023-08-04T14:59:36Z D! [agent] Starting service inputs
2023-08-04T14:59:36Z I! [inputs.mqtt_consumer] Connected [tcp://127.0.0.1:1883]
> mqtt_consumer,host=raspberrypi,topic=ahoy/HM-600/ch1/YieldDay value=0 1691161176252939542
2023-08-04T14:59:36Z D! [agent] Stopping service inputs
2023-08-04T14:59:36Z D! [inputs.mqtt_consumer] Disconnecting [tcp://127.0.0.1:1883]
2023-08-04T14:59:36Z D! [inputs.mqtt_consumer] Disconnected [tcp://127.0.0.1:1883]
2023-08-04T14:59:36Z D! [agent] Input channel closed
2023-08-04T14:59:36Z D! [agent] Stopped Successfully
EDIT: crosslink: help wanted: telegraf not collecting all mqtt data - idea? · Issue #1067 · lumapu/ahoy · GitHub