Hi,
I’m trying to parse an array with several measurements but I’m unable to solve it. I tried to find a solution but it seems that json_v2 is unable to do what I want. I’m here to ask if I oversaw a feature or if I have to find a completely different solution to fetch my data.
My JSON:
{
"applicationID":"1",
"applicationName":"Test",
"deviceName":"TcsSensorNode",
"deviceProfileName":"TcsSensor",
"deviceProfileID":"100ca98d-e075-4b1b-8cd3-41edbab355f5",
"devEUI":"27c0817d2aba3052",
"rxInfo":[
{
"gatewayID":"b827ebfffeaa4582",
"uplinkID":"659cbfab-3216-42fd-9f71-f2c470b7f9da",
"name":"local",
"rssi":-60,
"loRaSNR":7.5
},
{
"gatewayID":"ca925641ce08b33e",
"uplinkID":"15ca3b44-17a0-4662-82c9-aa23b40e16eb",
"name":"local",
"rssi":-98,
"loRaSNR":4.2
}
],
"txInfo":{
"frequency":868500000,
"dr":5
},
"adr":true,
"fCnt":71,
"fPort":2,
"data":"AGhCAGcA0g==",
"object":{
"humiditySensor":{
"0":33,
"1":25.5
},
"temperatureSensor":{
"0":21,
"1":19.3
}
}
}
The problem is that that in the rxInfo
array only the second values are used. Solutions I found through googling was that the array might need to be flattened first. But I can’t change the format of this. If I write my own application to receive the values I don’t need Telegraf anymore I can directly push to the database.
The current config:
[[inputs.mqtt_consumer.json_v2]]
measurement_name = "sensors_test2"
[[inputs.mqtt_consumer.json_v2.object]]
path = "rxInfo"
included_keys = ["rssi", "loRaSNR"]
[inputs.mqtt_consumer.json_v2.object.fields]
rssi = "float"
loRaSNR = "float"
[[inputs.mqtt_consumer.json_v2.object]]
path = "txInfo"
Hope somebody knows a solution. Thank you