Routing nested json objects to different measurements

Dimitris_Mamalis
Thu, 14 Mar 2024 11:34:33 +0000
Telegraf

Hi there,
i am using [[inputs.mqtt_consumer]] and json_v2 to parse the payload of incoming messages.
I would like to split the incoming message to two different measurements.
I tried having multiples of the json_v2 parser but it appears that only the last gets emitted.

[[[inputs.mqtt_consumer.json_v2]]
        measurement_name = "data"
        [.........]
[[[inputs.mqtt_consumer.json_v2]]
        measurement_name = "metadata"
        [.........]

Incoming message example:

{
    "id": "7A",
    "data": {
        "payload": {
            "temp": 3.09,
            "hum": 19.21,
        },
        "status": "success"
    },
    "metadata": [
        {
            "channel": 7,
            "frequency": 868.5,
        }
    ]
}

Desired output

data,id=7A temp=3.09,hum=19.21
metadata,id=7A channel=7, frequency=868.5

2 posts - 2 participants