Returning two metrics for each label set

I have this query that returns the slowest request with their request times in a grafana table widget:

topk(10, quantile_over_time(0.95, {container="nginx"} | json | request_time > 1 | unwrap request_time | __error__="" [15m]) by (request_method, request_uri))

Which returns a list of urls with their relative duration, how can I add another column with the number of requests for the pairs request_method, request_uri returned in the first query? E.g. returning multiple values from a single query?

I’ve tried to use and with another query like

sum by (request_method, request_uri) (count_over_time({container="nginx"} | json |  __error__="" [1h]))

but the problem in that case is that there are more than 500 series

I was able to find the solution:

  • use the first query as usual
  • use the second query and the first query, this way the second query only uses series from the first query
  • use the merge transformation to merge multiple frames into a single table with multiple columns, one for each value