简体   繁体   English

使用 Prometheus 的 InfoMetricFamily 在 Grafana 中进行表格可视化

[英]Make table visualization in Grafana using Prometheus's InfoMetricFamily

I have following code:我有以下代码:

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

that supply Prometheus with following metric:为 Prometheus 提供以下指标:

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

I would like to build table dashboard in Grafana where name , status , value will be columns.我想在 Grafana 中构建表仪表板,其中namestatusvalue将是列。 How could I do this?我怎么能这样做?

Since Grafana v4.3 , the table panel supports the display of Prometheus labels.从 Grafana v4.3 开始表格面板支持 Prometheus 标签的显示。

To create the display, add a table panel in your dashboard:要创建显示,请在仪表板中添加一个表格面板:

  1. In the Query tabQuery选项卡中
    1. Toggle Instant to True and set Format to Table ;Instant切换为 True 并将Format设置为Table if you start by filling the query you may have a BIG response freezing your window如果您从填写查询开始,您可能会收到一个很大的响应,冻结您的window
    2. Write your query in Metrics : in your case health_infoMetrics中写下您的查询:在您的情况下health_info
  2. In the visualization Tab, you will control the columns that should appear and format their display在可视化选项卡中,您将控制应显示的列并设置其显示格式
    1. Remove the Time column (unless you need it, personally I rarely do)删除Time列(除非你需要它,我个人很少这样做)
    2. Set the catchall rule /.*/ to Type Hidden ;将包罗万象的规则/.*/设置为 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)使用Add column style隐藏要显示的列,方法是在Apply to columns named中键入 then name(完成效果很好)
    4. You can adjust name of column in Column Header and tune the display您可以调整Column Header并调整显示

NOTE: currently, you cannot modify the order of the columns.注意:目前,您无法修改列的顺序。

If you want to display multiple metrics on the same lines note that:如果您想在同一行显示多个指标,请注意:

  • all labels must match: remove conflicting ones by apply an aggregation function所有标签必须匹配:通过应用聚合 function 删除冲突的标签
  • the name of the metric is a label: you need also to get rid of __name__ label指标的名称是 label:您还需要摆脱__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添加第二个值时,第一个值的列名变为Value #A ,需要调整显示

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

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