5
votes

If I use the following query

topk(5,sum(container_memory_usage_bytes{kubernetes_container_name=~".+", kubernetes_namespace=~".+"}) by (kubernetes_namespace,kubernetes_container_name))

it returns 5 results as epxected.

However with

topk(5,sum(irate(container_cpu_usage_seconds_total{kubernetes_container_name=~".+", kubernetes_namespace=~".+"}[20s])) by (kubernetes_namespace,kubernetes_container_name))

around 18 results are returned. Any idea why this happens? And what I need to change in the second query to get only the top 5?

2

2 Answers

4
votes

Had the same issue, I switched on "Instant" on the query and I got the correct amount back

2
votes

Those are the same query from the topk standpoint, both should be returning no more than 5 results.

Would I be right in saying that you're not running this as a query, but actually as a graph? If so exactly which 5 do you want chosen?