简体   繁体   English

Prometheus 查询 - 按值分组并返回计数

[英]Prometheus Query - Group by values and return a count

I have a metric that returns a few unique values for each timeseries.我有一个指标,它为每个时间序列返回一些唯一值。 (This is from Prometheus Blackbox Exporter). (这是来自 Prometheus Blackbox Exporter)。 See example below请参阅下面的示例

在此处输入图像描述

How can I group these by value and return a count.如何按值对它们进行分组并返回计数。 The following is the expected outcome以下是预期的结果

{status="400"}      1
{status="0"}        0
{status="200"}      2

Use the following PromQL:使用以下 PromQL:

count_values("status", probe_http_status_code)

More info in Prometheus documentation here . Prometheus 文档中更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM