prometheus: convert zrepl_version_daemon to zrepl_start_time metric

closes https://github.com/zrepl/zrepl/pull/556
fixes #553
This commit is contained in:
Lapo Luchini 2022-01-12 16:52:58 +01:00 committed by Christian Schwarz
parent 0a6840273a
commit 4a27cc63a8
3 changed files with 17 additions and 7 deletions

View File

@ -249,7 +249,7 @@
"stack": true, "stack": true,
"steppedLine": false, "steppedLine": false,
"targets": [{ "targets": [{
"expr": "zrepl_version_daemon{job='$prom_job_name'}", "expr": "sgn(zrepl_start_time{job='$prom_job_name'})",
"format": "time_series", "format": "time_series",
"interval": "", "interval": "",
"intervalFactor": 1, "intervalFactor": 1,

View File

@ -16,6 +16,17 @@ Changelog
The changelog summarizes bugfixes that are deemed relevant for users and package maintainers. The changelog summarizes bugfixes that are deemed relevant for users and package maintainers.
Developers should consult the git commit log or GitHub issue tracker. Developers should consult the git commit log or GitHub issue tracker.
0.6 (Unreleased)
----------------
* `Feature Wishlist on GitHub <https://github.com/zrepl/zrepl/discussions/547>`_
* |break| |feature| convert Prometheus metric ``zrepl_version_daemon`` to ``zrepl_start_time`` metric
* The metric still reports the zrepl version in a label.
But the metric *value* is now the Unix timestamp at the time the daemon was started.
The Grafana dashboard in :repomasterlink:`dist/grafana` has been updated.
0.5 0.5
--- ---

View File

@ -34,20 +34,19 @@ func (i *ZreplVersionInformation) String() string {
i.Version, i.RuntimeGo, i.RuntimeGOOS, i.RuntimeGOARCH, i.RUNTIMECompiler) i.Version, i.RuntimeGo, i.RuntimeGOOS, i.RuntimeGOARCH, i.RUNTIMECompiler)
} }
var prometheusMetric = prometheus.NewUntypedFunc( var prometheusMetric = prometheus.NewGauge(
prometheus.UntypedOpts{ prometheus.GaugeOpts{
Namespace: "zrepl", Namespace: "zrepl",
Subsystem: "version", Name: "start_time",
Name: "daemon", Help: "zrepl daemon start time and version",
Help: "zrepl daemon version",
ConstLabels: map[string]string{ ConstLabels: map[string]string{
"raw": zreplVersion, "raw": zreplVersion,
"version_info": NewZreplVersionInformation().String(), "version_info": NewZreplVersionInformation().String(),
}, },
}, },
func() float64 { return 1 },
) )
func PrometheusRegister(r prometheus.Registerer) { func PrometheusRegister(r prometheus.Registerer) {
r.MustRegister(prometheusMetric) r.MustRegister(prometheusMetric)
prometheusMetric.SetToCurrentTime()
} }