hi
I’ve started using the httpjson plugin for collecting metrics via APIs.
this plugin creates fields automatically and it includes in the field name each interface name what makes it impossible to use variables in the query.
I’ve tried to do so using regular expirations, but beside /./ that just selected all fields I could really get any results.
more specific details:
im using API to collect the results of the sd-wan performance SLA check from my FortiGate.
it returning values of latency, packet loss, jitter etc. for every wan interface to various destinations.
the response looks like this:
indent preformatted text by 4 spaces
telegraf --config /etc/telegraf/telegraf.conf --test
2020-09-27T06:45:14Z I! Starting Telegraf 1.14.5
httpjson_sd_wan_stats,host=telegraf-upwork,server=https://172.17.200.1/api/v2/monitor/virtual-wan/health-check/select build=268,response_time=0.293239661,results_http\ check_wan1_jitter=10.928666,results_http\ check_wan1_latency=107.960655**,results_http\ check_wan1_packet_loss=0**,results_http\ check_wan1_packet_received=1426838,results_http\ check_wan1_packet_sent=1434961,results_http\ check_wan1_rx_bandwidth=111760,results_http\ check_wan1_session=60,results_http\ check_wan1_state_changed=1600866072,results_http\ check_wan1_tx_bandwidth=71906,results_http\ check_wan2_jitter=9.614668,results_http\ check_wan2_latency=107.431297,results_http\ check_wan2_packet_loss=0,results_http\ check_wan2_packet_received=748680,results_http\ check_wan2_packet_sent=1434961,results_http\ check_wan2_rx_bandwidth=15380,results_http\ check_wan2_session=2,results_http\ check_wan2_state_changed=1601187656,results_http\ check_wan2_tx_bandwidth=4193,results_ping\ check_wan1_jitter=0.0266,results_ping\ check_wan1_latency=39.58223,results_ping\ check_wan1_packet_loss=0,results_ping\ check_wan1_packet_received=497883,results_ping\ check_wan1_packet_sent=501163,results_ping\ check_wan1_rx_bandwidth=111760,results_ping\ check_wan1_session=59,results_ping\ check_wan1_state_changed=1600866072,results_ping\ check_wan1_tx_bandwidth=71906,results_ping\ check_wan2_jitter=0.0275,results_ping\ check_wan2_latency=39.608501,results_ping\ check_wan2_packet_loss=0,results_ping\ check_wan2_packet_received=409617,results_ping\ check_wan2_packet_sent=501163,results_ping\ check_wan2_rx_bandwidth=15380,results_ping\ check_wan2_session=1,results_ping\ check_wan2_state_changed=1601187656,results_ping\ check_wan2_tx_bandwidth=4193 1601189114000000000
indent preformatted text by 4 spaces
ive bolded all relevant packet loss metrics for this example.
i got 4 different valus 2 for each interface(wan1 and 2)
i preform 2 tests ping and http (different destinations)
and i want to pull all 4 in one query.
something like this
indent preformatted text by 4 spaces
SELECT mean(“results_ping check_wan1_packet_loss”) AS “packet_loss(ping check_wan1)”, mean(“results_ping check_wan2_packet_loss”) AS “packet_loss(ping check_wan2)”, mean(“results_http check_wan1_packet_loss”) AS “packet_loss(http check_wan1)”, mean(“results_http check_wan2_packet_loss”) AS “packet_loss(http check_wan2)” FROM “httpjson_sd_wan_stats” WHERE (“host” =~ /^$site$/) AND $timeFilter GROUP BY time($__interval) fill(null)
indent preformatted text by 4 spaces
how could i do that in one line when i know that test will name http or ping
and the interface name could be wan1/wan2/port1-30? is it even possible?
ill appreciate any feedback. ![]()
I’m using:
Telegraf 1.14.5
Influxdb 1.8.0-1
Grafana 7.0.5
thanks