How can I use Arithmetic Binary Operators in raw Loki row data?
For example, I have row with JSON {"total_duration_sec": 123, "total_items": 41}
and need to build graph by “total_duration_sec / total_items” formula.
I can build query like this:
avg_over_time({job="my-job"} | json | total_duration_sec [$__interval])
/
avg_over_time({job="my-job"} | json | total_items [$__interval])
But it will give me wrong results, because of averaging the value in each interval, so we will receive the avg(total_duration_sec) / avg(total_items)
, instead of avg(total_duration_sec / total_items)
!
So I need to have something like this:
avg_over_time(
({job="my-job"} | json | total_duration_sec)
/
({job="my-job"} | json | total_items)
[$__interval])
But this isn’t work.
Can anyone give me a working example, that show me exact calculated values?