I am trying to configure the HTTP input plugin using Telegraf, but I need to select certain metrics using the select expression and write them to a specific Influxdb database. I know how to select using jq, but I can't do it using a GJSON request.
My output look like this:
[
{
"properties": {
"headers": {
"database": "telegraf"
},
"content_type": "text/plain"
},
"payload": "net,cluster_id=cluster01,dc=dc02,host=specific_host01,instance=instance-00107205 network_write_packets=15100740,network_write_drops=0 1628285530000000000\n",
"payload_encoding": "string"
},
{
"properties": {
"headers": {
"database": "stats"
},
"content_type": "text/plain"
},
"payload": "dsk_stats,Region=Q3,host=specific_host01 disk_usage=8.344534641 1628285530000000000\n",
"payload_encoding": "string"
}
]
For choosing metrics by stats I'm using jq:
curl -s -H "content-type:application/json" localhost:8080 |jq '.[] | select(.properties.headers.database=="stats") | "\(.payload)"
dsk_stats,Region=Q3,host=specific_host01 disk_usage=8.344534641 1628285530000000000\n
Is it possible to make such json selection using the GJSON syntax?