Get components on a vector calculation in the same series

Referring to LogQL | Grafana Labs “The following example returns the rates requests partitioned by app and status as a percentage of total requests.” is done by summing by app and status for success, dividing by total requests. That’s fine and works. However I want to know the “scale” of the % so that I can alert on it.

For example, a 30% failure on 4 requests total vs a 30% failure on 50000 requests total.

Is there a way we can “union” the returned time series and include the total request count next to the % value? For example from the docs above, labels returned would be:

=>
[
  {app="foo", status="200", total_request_count="50000"} => 0.8
  {app="foo", status="400", total_request_count="3"} => 0.1
  {app="foo", status="500", total_request_count="100"} => 0.1
]

Then in alert message I can say:

${app} has a high failure rate, out of ${total_request_count} requests

Since this is for alerts I dont mind if I have to run the query multiple times. Since the range of the query is small.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.