From 6b3c7de72765cc9fbb1efc9210b46c839f4afcd1 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Tue, 7 Jul 2015 23:29:59 -0600 Subject: [PATCH] Export build information as metric. There is more build information that could be put into labels, but Version, Revision, and Branch seemed like the right level of detail to me. --- version/info.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/version/info.go b/version/info.go index 7c1f57227..835fc5ce6 100644 --- a/version/info.go +++ b/version/info.go @@ -13,6 +13,8 @@ package version +import "github.com/prometheus/client_golang/prometheus" + // Build information. Populated at build-time. var ( Version string @@ -32,3 +34,16 @@ var Map = map[string]string{ "buildDate": BuildDate, "goVersion": GoVersion, } + +func init() { + buildInfo := prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: "prometheus_build_info", + Help: "A metric with a constant '1' value labeled by version, revision, and branch from which Prometheus was built.", + }, + []string{"version", "revision", "branch"}, + ) + buildInfo.WithLabelValues(Version, Revision, Branch).Set(1) + + prometheus.MustRegister(buildInfo) +}