prometheus: expose zrepl version as const metric

This commit is contained in:
Christian Schwarz 2020-06-11 16:32:54 +02:00
parent 4b1b7a8561
commit 509185dfbe
2 changed files with 21 additions and 0 deletions

View File

@ -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)

View File

@ -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)
}