From 46fa84f9b07f9fae0d3d2cea32e03cab86dc2c73 Mon Sep 17 00:00:00 2001 From: Ben Ridley Date: Mon, 29 Aug 2022 22:01:06 -0700 Subject: [PATCH] Export extra version information Adds major version, minor version, and build number as independent labels when exporting OS info. Signed-off-by: Ben Ridley --- collector/os.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/collector/os.go b/collector/os.go index 571d0cba..b7673dfc 100644 --- a/collector/os.go +++ b/collector/os.go @@ -52,7 +52,7 @@ func NewOSCollector() (Collector, error) { OSInformation: prometheus.NewDesc( prometheus.BuildFQName(Namespace, subsystem, "info"), "OperatingSystem.Caption, OperatingSystem.Version", - []string{"product", "version"}, + []string{"product", "version", "major_version", "minor_version", "build_number"}, nil, ), PagingLimitBytes: prometheus.NewDesc( @@ -236,6 +236,9 @@ func (c *OSCollector) collect(ctx *ScrapeContext, ch chan<- prometheus.Metric) ( 1.0, fmt.Sprintf("Microsoft %s", pn), // Caption fmt.Sprintf("%d.%d.%s", nwgi.VersionMajor, nwgi.VersionMinor, bn), // Version + fmt.Sprintf("%d", nwgi.VersionMajor), // Major Version + fmt.Sprintf("%d", nwgi.VersionMinor), // Minor Version + bn, // Build number ) ch <- prometheus.MustNewConstMetric(