prometheus - 你可以在 promQL 查询中有多个聚合器吗
问题描述
在 influxQL 中,您可以使用多个聚合函数进行查询,如下所示:
SELECT MEAN(value), MIN(value) FROM measurement WHERE category= ...
在 promQl 中,您也可以指定聚合函数,例如 Avg:
Avg by (server) (HttpStatusCodes{category = 'Api.ResponseStatus'})
但我想知道您是否可以像在 influxQL 中一样在 promQl 中执行多个聚合器,如下所示:
Avg, Max by (server) (HttpStatusCodes{category = 'Api.ResponseStatus'})
解决方案
尝试以下MetricSQL查询:
with (m = HttpStatusCodes{category = 'Api.ResponseStatus'})
(
alias(max(max_over_time(m)) by (server), "max"),
alias(sum(sum_over_time(m)) by (server) / sum(count_over_time(m)) by (server), "avg")
)
推荐阅读
- setuid - 尝试使用 checkinstall 或 porg 了解 LD_PRELOAD 和 SUID/SGID
- c# - 使用 MVVM 从 ViewModel 中的窗口资源中选择 DataTemplate
- ruby-on-rails - Factory Bot 与命名空间模型故障的关联
- sql - ORACLE SQL检查表的行号是否为n,然后执行join
- javascript - 在Javascript中独立定位while循环的每个元素?
- git - 使用“git revert”和冲突。这是怎么发生的?
- jquery - 提交前验证字段
- python - 无法在本地使用 PySpark 从 AWS S3 路径读取 Avro 文件
- postman - 无法访问 Postman 预请求脚本中的 XML 响应
- angular - Angular:注销时销毁服务变量