I have a json response of the below format that I am trying to parse via inputs.http plugin of Telegraf.
{
"data": {
"results": [
{
"series": [
{
"columns": [
"time",
"tag_1",
"tag_2",
"tag_3",
"tag_4",
"tag_5",
"field_1",
"field_2",
"field_3",
"tag_6",
"tag_7",
"field_4",
"tag_8",
"field_5",
"tag_9",
"tag_10"
],
"name": "measurement_name",
"values": [
[
1593068400,
"01",
"01",
"0072",
"07",
"PLACEHOLDER",
"PLACEHOLDER",
0,
0,
"0072-01-01-07",
"PLACEHOLDER",
0,
"AB",
3,
"PLACEHOLDER",
"2.2"
],
[
1593068400,
"01",
"01",
"0072",
"09",
"PLACEHOLDER",
"PLACEHOLDER",
0,
0,
"0072-01-01-09",
"PLACEHOLDER",
0,
"BC",
4,
"PLACEHOLDER",
"2.2"
],
[
1593068400,
"01",
"01",
"0072",
"10",
"PLACEHOLDER",
"PLACEHOLDER",
0,
0,
"0072-01-01-10",
"PLACEHOLDER",
0,
"AB",
4,
"PLACEHOLDER",
"2.2"
]
]
}
],
"statement_id": 0
}
]
}
}
All of the documentation I have seen shows how to parse json if the tags/fields are keys of a json object. For example, telegraf/plugins/parsers/json at master · influxdata/telegraf · GitHub.
How can I parse a json object where the tags/fields and values are separated into separate lists?
Below is the relevant portion of my Telegraf configuration file so far.
[[inputs.http]]
#URL
urls = ["url"]
#http method
method = "POST"
#Parse `values` array only
json_query = "data.results.0.series.0"
#Exclude url and host items from tags
tagexclude = ["url", "host"]
#Overwrite measurement name from default `http` to `measurement_name`
name_override = "measurement_name"
## Optional HTTP headers
headers = {"cache-control" = "no-cache","content-type" = "application/json"}
## HTTP entity-body to send with POST/PUT requests.
body = "{\"measurement\":\"measurement_name\", \"time_filter\":[1593068400, 1593068800]}"
#Data from HTTP in JSON format
data_format = "json"