Hi Guys,
I’m able to get the value from Rest API call with Infinity plugin as data source for Grafana.
E.g. able to display value 12 as “TotalGrouop” on dashboard
able to display value 1000 as “TotalAmount” on dashboard as well.
My question, how to perform the math calculation between this two values?
AvgAmount = TotalAmount/TotalGroup = 1000/12
=======JSON file example===========
{
“TotalGroup” : 12,
“TotalAmount” : 1000
}
Thank you.
yosiasz
September 25, 2024, 7:13pm
2
welcome @bestvincent
or UQL jsonata (UQL )
parse-json
| jsonata "$map($, function($v, $i, $a) { $v.TotalAmount/$v.TotalGroup})"
Actually you don’t need UQL for writing JSONata. Simply select backend parser which is more powerful than UQL, then in the root selector you can write JSONata and get the data visualized.
or
$map($, function($v) { return {
"output": $v.TotalAmount / $v.TotalGroup
} })
@ yosiasz
Thank you, the transform method method worked for me. Although I couldn’t make UQL work.
@ yesoreyeram
Both methods worked for me!
Thank you guys help.
1 Like
Additional question:
What’s the best/easiest way to change the default Query name (e.g. A, B, C, D …) on dashboard?
I know we can configure override to replace fields Display Name.
Thanks.