Hello,
I have the following type of metric being published on MQTT broker:
{
"dev":[
{
"id":"office-32413",
"l_seen":1659379835655,
"mac":"deadbeefdead"
},
{
"id":"office-56228",
"l_seen":1659379835706,
"mac":"deaddeaddead"
}
],
"n":2,
"of":2
}
Pagination is here because the total count of the dev
items may be super high, like thousands.
Before I added this pagination feature the message was just an array:
{
"id":"office-32413",
"l_seen":1659379835655,
"mac":"deadbeefdead"
},
{
"id":"office-56228",
"l_seen":1659379835706,
"mac":"deaddeaddead"
}
]
and the telegraf configuration for it that was perfectly working is:
[[inputs.mqtt_consumer]]
servers = ["tcp://{{inventory_hostname}}:1883"]
name_override = "engine-health-tags"
qos = 0
connection_timeout = 30
topics = [
"engine/+/h/+/t",
]
persistent_session = true
client_id = "engine-health-tags-telegraf"
data_format = "json"
json_string_fields = ["mac"]
tag_keys = ["mac"]
What I am trying to achieve now is use Telegraf’s parser to get only the dev
array from the incoming json and send it to Influxdb as a metric.
How should I change the above telegraf’s configuration to parse only the dev
object from the paginated json so I keep the same data in the influx db as when there was no pagination?