本文介绍了使用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中构建表仪表板,其中name
,status
,value
将是列.我该怎么办?
I would like to build table dashboard in Grafana where name
, status
, value
will be columns. How could I do this?
推荐答案
从Grafana开始 v4.3 ,表格面板支持显示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:
- 在
Query
选项卡中
- 将
Instant
切换为True并将Format
设置为Table
;如果您先填写查询,则可能会收到 BIG 响应,冻结窗口 - 在
Metrics
中写您的查询:就您而言health_info
- Toggle
Instant
to True and setFormat
toTable
; if you start by filling the query you may have a BIG response freezing your window - Write your query in
Metrics
: in your casehealth_info
- 删除
Time
列(除非您需要它,我个人很少这样做) - 将总体规则
/.*/
设置为Hidden
类型;它将隐藏您的所有列 - 使用
Add column style
来隐藏要显示的列,方法是在Apply to columns named
中键入然后输入名称(完成效果很好) - 您可以在
Column Header
中调整列的名称并调整显示内容
- Remove the
Time
column (unless you need it, personally I rarely do) - Set the catchall rule
/.*/
to TypeHidden
; it will hide all your columns - Use
Add column style
to hide a column to display by typing then name inApply to columns named
(the completion works well) - 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中进行表格可视化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!