mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-28 04:02:21 -04:00
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.
This commit is contained in:
parent
1d6d39a9ed
commit
6b3c7de727
1 changed files with 15 additions and 0 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue