【问题标题】:Display table for series with label's occurrence count greater than N in Prometheus在 Prometheus 中显示标签出现次数大于 N 的系列表
【发布时间】:2018-08-28 02:41:33
【问题描述】:

在 Prometheus 中,给出了下面的指标定义,我如何为指标系列中排名前 5 位的重复设备呈现一个表格?

top_5_noisy_devices:

    { "device" : "1234", "type" : "foo"}
    { "device" : "1234", "type" : "foo"}
    { "device" : "1234", "type" : "foo"}
    { "device" : "2345", "type" : "foo"}
    { "device" : "4231", "type" : "foo"}
    { "device" : "4354", "type" : "foo"}

我想在 Grafana 中为上述标签呈现一个表格,以显示设备 1234 是所选时间段内的嘈杂设备。 我尝试了 topk 运算符,但它呈现超过 3 个。(我在表中看到 100 行而不是 3 行) https://www.robustperception.io/graph-top-n-time-series-in-grafana 声称支持 Grafana 中的 topk。但我不明白如何使它适应表格。

【问题讨论】:

    标签: grafana prometheus promql


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      我使用下面的方法来显示一个表格。

      • 用少量静态值定义一个变量interval(示例)

      • 在 Grafana 中添加面板(作为表格或您选择的饼图)并在查询下方使用

      topk(5,round(increase(top_5_noisy_devices{type="Foo"}[$interval])))

      • 图例格式为 {{ device }}
      • 格式为 -> 时间序列
      • 图例格式为 {{ device }}
      • 选择即时复选框

      使用变量选择任何间隔下拉菜单会获取特定时期的 topk 数据。

      【讨论】:

        猜你喜欢
        • 2021-09-23
        • 1970-01-01
        • 1970-01-01
        • 2021-11-29
        • 2023-03-12
        • 2018-05-08
        • 1970-01-01
        • 2015-01-01
        • 2020-10-29
        相关资源
        最近更新 更多