Skip to content

topk by (label) over a temporal function collapses all groups into one result #714

Closed

Description

@milindsrivastava1997

Problem

topk by (job) (k, sum_over_time(...)/count_over_time(...)) returns a single result total instead of one winner per job group.

Queries and results

topk by (job) (1, sum_over_time(data[5m]))

  • Prometheus: {instance="i-2",job="backend"}=5600, {instance="i-2",job="frontend"}=2800, {instance="i-2",job="worker"}=8400
  • ASAPQuery: {instance="i-2",job="worker"}=8400

topk by (job) (1, count_over_time(data[5m]))

  • Prometheus: {instance="i-1",job="backend"}=5, {instance="i-1",job="frontend"}=5, {instance="i-1",job="worker"}=5
  • ASAPQuery: {instance="i-1",job="backend"}=5

Both sum_over_time and count_over_time wrapped in topk by (job) produce only one series total; every other job group is silently dropped. topk by (job, instance) over the same functions shows the same collapse.

Evidence

Confirmed via promql-compliance (aggregations suite, aggregations-dense-cadence dataset).

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions