Make table visualization in Grafana using Prometheus's InfoMetricFamily

早过忘川 提交于 2020-02-06 15:43:05

问题


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:

# 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. How could I do this?


回答1:


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. In the Query tab
    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
  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)
    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:

  • 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


来源:https://stackoverflow.com/questions/58627208/make-table-visualization-in-grafana-using-prometheuss-infometricfamily

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!