Skip to content
Snippets Groups Projects
Unverified Commit bd73825e authored by Nicolas Lamirault's avatar Nicolas Lamirault Committed by GitHub
Browse files

new Prometheus metrics build_info (#3558)

parent 6fca251d
Branches
Tags
No related merge requests found
......@@ -50,6 +50,15 @@ type serveOptions struct {
grpcAddr string
}
var buildInfo = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "build_info",
Namespace: "dex",
Help: "A metric with a constant '1' value labeled by version from which Dex was built.",
},
[]string{"version", "go_version", "platform"},
)
func commandServe() *cobra.Command {
options := serveOptions{}
......@@ -117,6 +126,10 @@ func runServe(options serveOptions) error {
logger.Info("config issuer", "issuer", c.Issuer)
prometheusRegistry := prometheus.NewRegistry()
prometheusRegistry.MustRegister(buildInfo)
recordBuildInfo()
err = prometheusRegistry.Register(collectors.NewGoCollector())
if err != nil {
return fmt.Errorf("failed to register Go runtime metrics: %v", err)
......@@ -684,3 +697,8 @@ func loadTLSConfig(certFile, keyFile, caFile string, baseConfig *tls.Config) (*t
}
return loadedConfig, nil
}
// recordBuildInfo publishes information about Dex version and runtime info through an info metric (gauge).
func recordBuildInfo() {
buildInfo.WithLabelValues(version, runtime.Version(), fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH)).Set(1)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment