I’m looking for some advice on how to format an INFLUX input to a particular JSON ouput format containing an array. I’m generating the INFLUX input, so there’s some flexibility there to combine into a single message or leave as multiple.
I presume another option would be to format INPUT as JSON directly. However, the majority of the other data inputs are using INFLUX format.
Expected JSON OUTPUT
{
“name”: “Stats-XyzUtilization”,
“tags”: {
“serialnumber”: “AB78CF2FB-1400”
};
“fields”: [
{
“min”: 32,
“max”: 61,
“avg”: 34,
“interval”: 10,
“samplePeriod”:5,
“xyz”:0
}
{
“min”: 20,
“max”: 63,
“avg”: 52,
“interval”: 10,
“samplePeriod”:5,
“xyz”:1
}
{
“min”: 81,
“max”: 99,
“avg”: 92,
“interval”: 10,
“samplePeriod”:5,
“xyz”:2
}
],
“lastChange”: 1234567890
}
Possible Influx INPUT (I’m generating this, so there is flexibility on how this is input into telegraf)
Stats-XyzUtilization,serialnumber=”AB78CF2FB-1400”,xyz=0 min=32,max=61,avg=34,interval=10,samplePeriod=5 timestamp=1234567890
Stats-XyzUtilization,serialnumber=”AB78CF2FB-1400”,xyz=1 min=20,max=63,avg=52,interval=10,samplePeriod=5 timestamp=1234567890
Stats-XyzUtilization,serialnumber=”AB78CF2FB-1400”,xyz=2 min=81,max=99,avg=92,interval=10,samplePeriod=5 timestamp=1234567890