Parsing JSON data into multiple entries

Hi,
I am trying to create a Telegraf config to parse the following JSON data into multiple entries:

{
    "IMEI": "5679789121",
    "Model": "X64B1",
    "temperature": 18.8,
    "humidity": 46.4,
    "interrupt": 0,
    "interrupt_level": 0,
    "battery": 3.57,
    "signal": 14,
    "1": [
        18.5,
        43.3,
        "2025/03/13 16:36:11"
    ],
    "2": [
        18.4,
        43.6,
        "2025/03/13 16:21:11"
    ],
    "3": [
        17.8,
        43.8,
        "2025/03/13 16:06:11"
    ],
    "4": [
        17.6,
        43.5,
        "2025/03/13 15:51:11"
    ],
    "5": [
        17.5,
        43.5,
        "2025/03/13 15:36:11"
    ],
    "6": [
        17.8,
        43.9,
        "2025/03/13 15:21:11"
    ],
    "7": [
        17.7,
        44.5,
        "2025/03/13 15:06:11"
    ],
    "8": [
        17.7,
        44.6,
        "2025/03/13 14:51:11"
    ]
}

This is data being captured from a sensor device. It sends the current information (temperature, humidity, battery, signal, etc.), but also the stored information (in this case 1-8). The device uploads once every x time, but captures every 14 minutes.
I would like to store the current information, but also the stored information. The first field in the array is temperature, next humidity, and at last the timestamp when captured.

I think what I am looking for is something like this:

time="2025/03/13 16:36:11",humidity=43.3,temperature=18.5

time="2025/03/13 16:21:11",humidity=43.6,temperature=18.4

time="2025/03/13 16:06:11",humidity=43.8,temperature=17.8

time="2025/03/13 15:51:11",humidity=43.5,temperature=17.6

and so on.
Ideally the time should become the data timestamp.

I’ve looked into both json_v2 and xpath input. But got stuck on both, without any usefull result.

I had a similar situation where I needed to pull back data from a device on a specific interval and with that API call it would include the last x mins of data (that matched the interval) with a very small granularity that all needed to be printed and stored. I went the route of a python script that pulled back, parsed, and sent the data that was executed with the inputs.exec plugin.

1 Like