为什么我的 Telegraf MQTT 数据中缺少一些完整的子主题?

Why are some entire sub topics absent from my Telegraf MQTT data?

我正在 运行 InfluxDB 和 Telegraf 将 MQTT 数据提取到数据库中。我有一个奇怪的行为,我丢失了一些我应该使用 Telegraf 摄取的数据。我看到大量 MQTT 数据,来自主题和子主题,它们是缺失数据的兄弟姐妹,但仍然缺少一些数据。我也没有在日志中看到任何指示错误的信息。这是我的 telegraf.conf

[[outputs.influxdb_v2]]
  urls = ["http://influxdb:8086"]
  token = "$KTS_TELEMETRY_INFLUXDB_TOKEN"
  organization = "$KTS_TELEMETRY_INFLUXDB_ORG"
  bucket = "$KTS_TELEMETRY_INFLUXDB_BUCKET"

[[inputs.mqtt_consumer]]
  data_format = "json"
  servers = ["tcp://10.0.200.10:1883"]
  topics = [ 
    "/sample/#"
  ]

我正在获取有关 /sample/runout/data 等主题和其他子主题的数据,但我没有获得有关我的主题之一 /sample/runout/status 的任何数据。我可以看到肯定有关于该主题的数据,但是,运行 此命令不断为我提供大量数据。

mosquitto_sub -h 10.0.200.10 -t /sample/runout/status

运行 与 /sample/runout/data 相同的命令也显示很多相同的消息。奇怪的是 /sample/runout/data 出现在数据库中,但 /sample/runout/status 没有。

这是发布到 /sample/runout/status

的消息示例之一
{"RollingReady":false,"TwinSAFE_enable":false,"ReceivedDataValid":false,"FramesAligned":false,"FramesCoupled":false,"inner_frame":{"virtualAxisJogEnabled":true,"virtualAxisJogReady":false,"motionReady":false,"motionAccepted":false},"outer_frame":{"virtualAxisJogEnabled":true,"virtualAxisJogReady":false,"motionReady":false,"motionAccepted":false},"inner_big_vee":{"axesInPosition":true,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"outer_big_vee":{"axesInPosition":true,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_i1":{"axesInPosition":true,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_a1":{"axesInPosition":true,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_a2":{"axesInPosition":true,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_a3":{"axesInPosition":true,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_b1":{"axesInPosition":false,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_b2":{"axesInPosition":false,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_b3":{"axesInPosition":false,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_b4":{"axesInPosition":false,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_c1":{"axesInPosition":false,"enabled":false,"error":false,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_c2":{"axesInPosition":false,"enabled":false,"error":true,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_c3":{"axesInPosition":false,"enabled":false,"error":true,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_c4":{"axesInPosition":false,"enabled":false,"error":true,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_d1":{"axesInPosition":false,"enabled":false,"error":true,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false},"support_d2":{"axesInPosition":false,"enabled":false,"error":true,"initialized":false,"operational":false,"payoutMode":false,"payoutReady":false,"ready":false,"rollingMode":true,"rollingReady":false}}

这里我能做的唯一重要的事情是这个子主题中的所有值都是布尔值,但 InfluxDB 很好地支持布尔值。我错过了什么?我一直没能找到任何有用的方法来调试它。

这里的答案原来是输入data_format="json"不支持布尔值。我需要升级到 json_v2。我不太清楚如何获得完全相同的行为,因为文档不是很好。但我最终得到了这个并且它工作得很好。

[[outputs.influxdb_v2]]
  urls = ["http://influxdb:8086"]
  token = "$KTS_TELEMETRY_INFLUXDB_TOKEN"
  organization = "$KTS_TELEMETRY_INFLUXDB_ORG"
  bucket = "$KTS_TELEMETRY_INFLUXDB_BUCKET"


[[inputs.mqtt_consumer]]
  data_format = "json_v2"
  servers = ["tcp://10.0.200.10:1883"]
  topics = [ 
    "/sample/#"
  ]
  [[inputs.mqtt_consumer.json_v2]]
    [[inputs.mqtt_consumer.json_v2.object]]
      path = "@this"
      excluded_keys = []