0

在 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'}) 
4

1 回答 1

1

尝试以下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")
)
于 2021-02-05T08:39:59.977 回答