Search code examples
mqttinfluxdbtelegraf

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


I am running InfluxDB and Telegraf ingesting MQTT data into the database. I have an odd behavior where in I am missing some data that I should be ingesting with Telegraf. I'm seeing loads of MQTT data, from topics and subtopics that are siblings of the missing data, but yet some data is still missing. I'm also not seeing anything indicating an error in the logs. This is my 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/#"
  ]

And I am getting data on topics like /sample/runout/data and other subtopics, but I'm not getting anything on one of my topics, /sample/runout/status. I can see that there definitely is data coming across the wire on that topic however, running this command gives me plenty of data constantly.

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

Running the same command with /sample/runout/data also shows lots of messages just the same. Oddly /sample/runout/data is showing up in the database but /sample/runout/status is not.

This is one example of a message published to /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}}

The only thing I can thing of of significance here is that all of the values in this sub topic are booleans but the InfluxDB supports booleans just fine. What am I missing? I haven't been able to find any helpful ways to debug this.


Solution

  • The answer here turned out to be that the input data_format="json" does not support booleans. I needed to upgrade to json_v2. This was not exactly clear to me how to just get the same exact behavior because the documentation wasn't really great. But I ended up with this and it works just fine.

    [[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 = []