使用Prometheus的InfoMetricFamily在Grafana中进行表格可视化 [英] Make table visualization in Grafana using Prometheus's InfoMetricFamily

查看:455
本文介绍了使用Prometheus的InfoMetricFamily在Grafana中进行表格可视化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

c = InfoMetricFamily("health", "Health Monitoring")
c.add_metric(labels=name, value={"name": name, "status": status, "value": value})

为普罗米修斯提供以下指标:

that supply Prometheus with following metric:

# HELP health_info Health Monitoring
# TYPE health_info gauge
health_info{name="external",status="danger",value="N\\A"} 1.0

我想在Grafana中构建表仪表板,其中namestatusvalue将是列.我该怎么办?

I would like to build table dashboard in Grafana where name, status, value will be columns. How could I do this?

推荐答案

从Grafana开始表格面板支持显示Prometheus标签.

Since Grafana v4.3, the table panel supports the display of Prometheus labels.

要创建显示,请在仪表板上添加表格面板:

To create the display, add a table panel in your dashboard:

  1. Query选项卡中
  1. Instant切换为True并将Format设置为Table;如果您先填写查询,则可能会收到 BIG 响应,冻结窗口
  2. Metrics中写您的查询:就您而言health_info
  1. Toggle Instant to True and set Format to Table; if you start by filling the query you may have a BIG response freezing your window
  2. Write your query in Metrics: in your case health_info

  • 在可视化选项卡中,您将控制应显示的列并设置其显示格式

  • In the visualization Tab, you will control the columns that should appear and format their display

    1. 删除Time列(除非您需要它,我个人很少这样做)
    2. 将总体规则/.*/设置为Hidden类型;它将隐藏您的所有列
    3. 使用Add column style来隐藏要显示的列,方法是在Apply to columns named中键入然后输入名称(完成效果很好)
    4. 您可以在Column Header中调整列的名称并调整显示内容
    1. Remove the Time column (unless you need it, personally I rarely do)
    2. Set the catchall rule /.*/ to Type Hidden; it will hide all your columns
    3. Use Add column style to hide a column to display by typing then name in Apply to columns named (the completion works well)
    4. You can adjust name of column in Column Header and tune the display

  • 注意:当前,您无法修改列的顺序.

    NOTE: currently, you cannot modify the order of the columns.

    如果要在同一行上显示多个指标,请注意:

    If you want to display multiple metrics on the same lines note that:

    • 所有标签必须匹配:通过应用聚合函数删除有冲突的标签
    • 指标的名称是标签:您还需要摆脱__name__标签
    • 添加第二个值时,第一个值的列名称更改为Value #A,并且需要调整显示内容
    • all labels must match: remove conflicting ones by apply an aggregation function
    • the name of the metric is a label: you need also to get rid of __name__ label
    • When adding the second value, the name of the column of the first value changes to Value #A and the display needs to be adjusted

    这篇关于使用Prometheus的InfoMetricFamily在Grafana中进行表格可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆