按聚合返回的度量值分组

发布于 2025-01-15 07:16:43 字数 379 浏览 2 评论 0 原文

我正在按组(实例)获取度量(阶段)的最大值,然后我想按最大阶段显示实例数是多少。

在 SQL 中,这将是:

select max_stage, count(*)
from
  (select instance, max(stage) as max_stage 
   from table 
   group by instance
  ) x
group by 
  max_stage 

使用 PromQL,这不起作用:

count by (stage) ((max by (instance) (stage)))

如何在外部聚合中引用最大阶段?

I am taking maximum value of a measure (stage) by group (instance) and then I want to show by maximum stage, what is the number of instances.

In SQL, this would be:

select max_stage, count(*)
from
  (select instance, max(stage) as max_stage 
   from table 
   group by instance
  ) x
group by 
  max_stage 

With PromQL, this does not work:

count by (stage) ((max by (instance) (stage)))

How do I reference max stage in the outer aggregation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酒浓于脸红 2025-01-22 07:16:43

使用 count_values 而不是 count

count_values ("some_name", max by (instance) (stage))

https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators

Use count_values instead of count:

count_values ("some_name", max by (instance) (stage))

https://prometheus.io/docs/prometheus/latest/querying/operators/#aggregation-operators

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文