diff --git a/daemon/daemon.go b/daemon/daemon.go index 4c354af..f6a90bc 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -95,6 +95,7 @@ func Run(ctx context.Context, conf *config.Config) error { } // register global (=non job-local) metrics + version.PrometheusRegister(prometheus.DefaultRegisterer) zfscmd.RegisterMetrics(prometheus.DefaultRegisterer) trace.RegisterMetrics(prometheus.DefaultRegisterer) endpoint.RegisterMetrics(prometheus.DefaultRegisterer) diff --git a/version/version.go b/version/version.go index 19e7aa9..1723179 100644 --- a/version/version.go +++ b/version/version.go @@ -3,6 +3,8 @@ package version import ( "fmt" "runtime" + + "github.com/prometheus/client_golang/prometheus" ) var ( @@ -29,3 +31,21 @@ func (i *ZreplVersionInformation) String() string { return fmt.Sprintf("zrepl version=%s GOOS=%s GOARCH=%s Compiler=%s", i.Version, i.RuntimeGOOS, i.RuntimeGOARCH, i.RUNTIMECompiler) } + +var prometheusMetric = prometheus.NewUntypedFunc( + prometheus.UntypedOpts{ + Namespace: "zrepl", + Subsystem: "version", + Name: "daemon", + Help: "zrepl daemon version", + ConstLabels: map[string]string{ + "raw": zreplVersion, + "version_info": NewZreplVersionInformation().String(), + }, + }, + func() float64 { return 1 }, +) + +func PrometheusRegister(r prometheus.Registerer) { + r.MustRegister(prometheusMetric) +}