I have system that provides status information through an HTTP call returning JSON code. One section of the JSON looks like:
"link_info": {
"10.88.42.36": {
"neighborLinkQuality": 0.71699999999999997,
"noise": -95,
"linkQuality": 1,
"linkType": "RF",
"hostname": "KJ6WEG-OAK-Griz-SectorM5.local.mesh",
"tx_rate": 19.5,
"olsrInterface": "wlan0",
"rx_rate": 19.5,
"signal": -81
},
"10.111.157.186": {
"neighborLinkQuality": 1,
"linkQuality": 1,
"hostname": "KK6RUH-Oakland-Nanobeam-M5.local.mesh",
"olsrInterface": "eth0.2",
"linkType": "DTD"
}
},
This results in fields in Influx like link_info_10.100.98.190_linkQuality and link_info_10.88.42.36_rx_rate. I would like to see these fields be link_info_linkQuality and link_info_rx_rate with a tag with the IP address but cannot figure out how to configure Telegraf to do this.
Ideally, the JSON code would originally look like:
"link_info": [
{"IPAddress": "10.88.42.36",
"neighborLinkQuality": 0.71699999999999997,
"noise": -95,
"linkQuality": 1,
"linkType": "RF",
"hostname": "KJ6WEG-OAK-Griz-SectorM5.local.mesh",
"tx_rate": 19.5,
"olsrInterface": "wlan0",
"rx_rate": 19.5,
"signal": -81
},
{"IPAddress": "10.111.157.186",
"neighborLinkQuality": 1,
"linkQuality": 1,
"hostname": "KK6RUH-Oakland-Nanobeam-M5.local.mesh",
"olsrInterface": "eth0.2",
"linkType": "DTD"
}
},
but alas I’m currently not able to change the code to make that happen. It’s written in Lua on an embedded system and that’s just not something I can work with right now.
My current thought is to skip Telegraf and write a Python program that runs periodically to read the JSON, adjust to the desired format and then write to the Influx database.
Any other suggestions on how I can do the transformations I’m looking for?
Thanks!