Telegraf MQTT Json parsing from Helium LoRaWAN

I am trying to read in sensor data from a sensor on the Helium LoRaWAN network. The data is making it into Influx via Telegraf and my Mosquito MQTT server, however, Telegraf is not parsing the data correctly.

Here is the raw JSON data:

{"app_eui":"A840412C81822E90","dc":{"balance":9987579,"nonce":2},"decoded":{"payload":{"BatV":2.745,"Ext_sensor":"Temperature Sensor","Hum_SHT":"53.0","TempC_DS":"-20.56","TempC_SHT":"-21.39"},"status":"success"},"dev_eui":"A840417C51822E90","devaddr":"0E000048","fcnt":6071,"hotspots":[{"channel":12,"frequency":904.7000122070313,"id":"112wi66efGeQimX7T9tNgzC2YEAzSGAs462JAPVJttB9KxNd163x","lat":30.271362508184776,"long":-95.58099270578788,"name":"silly-grey-raccoon","reported_at":1609906744,"rssi":-91.0,"snr":9.75,"spreading":"SF10BW125","status":"success"}],"id":"f8c272f7-dc7a-46d5-abbe-5666d5cbf86b","metadata":{"labels":[{"id":"3aa0f4b6-eaef-4a57-bbc8-0d1d6916579c","name":"mqtt","organization_id":"fcf6a45f-c2d4-4f71-98ea-1ed68149accf"},{"id":"b3b7688e-9b90-4642-b5fe-96a9d25b94ed","name":"datacake","organization_id":"fcf6a45f-c2d4-4f71-98ea-1ed68149accf"}],"organization_id":"fcf6a45f-c2d4-4f71-98ea-1ed68149accf"},"name":"RK-Temp","payload":"yrn3pQISAff4f/8=","payload_size":11,"port":2,"reported_at":1609906744}

The problem is that Telegraf is not parsing all of the key pairs. Specifically, I am trying to read in the following info:

{“BatV”:2.745,“Ext_sensor”:“Temperature Sensor”,“Hum_SHT”:“53.0”,“TempC_DS”:"-20.56",“TempC_SHT”:"-

Any thoughts as to why it will not read/parse this info?

Sorry to bump this, but I am still struggling with getting this right. Is it even possible to read all the data from a JSON output no matter how deep it is located?


It could be that you need to set those in either json_string_fields or tag_keys. As you can see in the json parser docs it says:

NOTE: All JSON numbers are converted to float fields. JSON strings and booleans are
ignored unless specified in the tag_keys or json_string_fields options.

So for your use case if you want them as fields either setting them in there like below or put them in tag_key if you are wanting them as tags.

  data_format = "json"
  files = ["example"]
  json_string_fields = ["decoded_payload_BatV","decoded_payload_Ext_sensor", "decoded_payload_Hum_SHT", "decoded_payload_TempC_DS", "decoded_payload_TempC_SHT"]

If you want all of the keys under decoded_payload added as fields or tags you can also use glob matching like so:

json_string_fields = ["decoded_payload_*"]

Let me know if that helps.

If not if you could share your config and output to stdout by adding this to your config -

  data_format = "influx"