Formatting influx INPUT to specific JSON output containing an array

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

Hi!

Taking a look at your Line Protocol input, the only comment I have is that tags, like serialnumber and xyz are normally strings. Keep that in mind.

As far as your output, what plugin were you planning to use with telegraf as your destination? Is it you just want it to be JSON data? or are you using it to a specific service or tool?

For now, tha plan is to use HTTP output plug with JSON data format. I’ve looked at possibly creating a new serializer or adding an option to the batch_mode for JSON serializer similar to the multimetric option in the Splunk serializer. However, I was hoping for an option that didn’t require code changes to telegraf.