> For the complete documentation index, see [llms.txt](https://bohans.gitbook.io/devops/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bohans.gitbook.io/devops/prometheus/promql/promql-ju-he-cao-zuo.md).

# PromQL 聚合操作

Prometheus 提供了下列聚合操作符：

* `sum` (求和)
* `min` (最小值)
* `max` (最大值)
* `avg` (平均值)
* `stddev` (标准差)
* `stdvar` (标准方差)
* `count` (计数)
* `count_values` (对 value 进行计数)
* `bottomk` (后 n 条时序)
* `topk` (前 n 条时序)
* `quantile` (分位数)

使用聚合操作的语法如下：

```markup
<aggr-op>([parameter,] <vector expression>) [without|by (<label list>)]
```

* 只有`count_values`，`quantile`，`topk`，`bottomk`支持参数（parameter）。
* **without** 用于从计算结果中移除列举的标签，而保留其它标签。**by** 则正好相反，结果向量中只保留列出的标签，其余标签则移除。
