如何在Grafana 7.2.1中显示Windows Node Exporter的version标签值?
version Label in Grafana 7.2.1 Got it, let's work through this step by step—since you're trying to pull that version tag from windows_os_info and display it alone in Grafana 7.2.1, here are actionable fixes and checks to try:
First, confirm Prometheus is actually receiving the
versionlabel
Head over to your Prometheus UI (usually athttp://<your-prometheus-ip>:9090) and run the querywindows_os_info. Look at the results—do you see theversiontag listed under the labels for the metric? If not, double-check your Windows Node Exporter config: make sure theoscollector is enabled (it should be by default, but sometimes custom configs disable it), and that you're running a Node Exporter version that exposes this tag.Pick the right Grafana panel type
Graph panels are for time-series data, so they won't work well for showing a single static label value. Instead, use either a Stat Panel or Text Panel:- Stat Panel Setup:
- Create a new Stat panel and select your Prometheus data source.
- In the query editor, enter
windows_os_info{instance="<your-node-exporter-instance>"}—replace the instance filter with your actual Node Exporter address (likewin-server-01:9182) to avoid returning multiple series (which would cause aggregation and hide the label). - Go to Panel Options > Value and set it to
Last(since this is a static value that doesn't change over time). - Under Value Options, you can customize how it displays—toggle "Show value labels" if you want to see the
versionkey alongside the value, or adjust the formatting to just show the version string.
- Text Panel Setup:
- Create a new Text panel and switch to Markdown mode.
- Use Grafana's template syntax to pull the label value directly:
Note: In Grafana 7.2.1, this template function should work, but if you hit issues, you can also use the Explore panel to copy the exact label value and hardcode it temporarily (though dynamic is better).Windows OS Version: {{ query_result("windows_os_info{instance=\"your-node-exporter-instance\"}") | label_value("version") }}
- Stat Panel Setup:
Fix aggregation issues
If your query returns multiple time series (e.g., multiple Windows servers), Grafana will automatically aggregate results (like averaging or summing), which strips out labels. Always add aninstancefilter to narrow it down to a single server so the label stays intact.Verify your Grafana data source config
Double-check your Prometheus data source in Grafana: go to Configuration > Data Sources, select your Prometheus source, and click Test to confirm connectivity. If the test fails, fix the URL or authentication settings first—no data will show up if Grafana can't reach Prometheus.Use the Explore panel to debug
Open Grafana's Explore tab (the compass icon in the left sidebar), select your Prometheus data source, and runwindows_os_info. If you can see theversionlabel here, the problem is in your panel configuration. If you don't see it here, the issue is upstream—either Node Exporter isn't sending it, or Prometheus isn't scraping it correctly.
内容的提问来源于stack exchange,提问作者james

