You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于Prometheus InfoMetricFamily在Grafana构建指定列的表格面板?

How to Build a Grafana Table Dashboard for Your Prometheus health_info Metrics

Got it, let's break down exactly how to turn that Prometheus metric into a clean table in Grafana with name, status, and value as your columns. Here's a step-by-step guide:


Step 1: Create a New Table Panel

  • Open your Grafana dashboard (or create a new one)
  • Click Add panel → Select Table as the visualization type

Step 2: Write the PromQL Query

In the query editor, select your Prometheus data source and enter this simple query:

health_info

This pulls in all instances of your health_info gauge metric, including all its attached labels (name, status, value).

Step 3: Convert Labels to Table Columns

By default, Grafana will show the Time and Value columns, but we need to extract the labels into separate columns. Here's how:

  • Switch to the Transform tab in the panel editor
  • Click Add transformation → Select Labels to Fields
    • This will automatically pull every label from your metric into its own column (you'll see name, status, value appear as new columns)
  • Optional: Remove unnecessary columns (like Time or the original Value column, since it's always 1.0 for your metric) by clicking the eye icon next to the column name in the table preview.
  • Rename columns: Go to the Panel options tab → Under Table options, find the Column styles section. You can set friendly names like Name instead of label_name, Status instead of label_status, etc.
  • Add conditional coloring: For the Status column, you can set cell colors based on the value (e.g., red for "danger", green for "ok"). In Column styles, select the Status column, set Color to "Thresholds", and define your color rules (e.g., "danger" = red, "ok" = green).

Why This Works

Your health_info metric stores all the relevant data (name, status, value) as Prometheus labels. Grafana's Labels to Fields transformation is perfect here—it takes those label key-value pairs and turns them into proper table columns, which is exactly what you need for your dashboard.


内容的提问来源于stack exchange,提问作者Rudziankoŭ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:21:57