mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-24 09:24:09 +01:00
prometheus: expose zrepl version as const metric
This commit is contained in:
parent
4b1b7a8561
commit
509185dfbe
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user