From 6136e08bbda2b5cd1acaf189961c9feec48e7ebd Mon Sep 17 00:00:00 2001 From: Valentin Doreau Date: Fri, 15 Nov 2024 16:47:30 +0100 Subject: [PATCH] feat: also export app-exporter version --- app_exporter.go | 3 +++ apps/metrics.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/app_exporter.go b/app_exporter.go index afb81fe..875c93f 100644 --- a/app_exporter.go +++ b/app_exporter.go @@ -55,6 +55,9 @@ func main() { } func RecordMetrics(m apps.Metrics) { + // export the app-exporter version + m.Version.With(prometheus.Labels{"version": VERSION}) + for { m.Reset() diff --git a/apps/metrics.go b/apps/metrics.go index 1e19230..8224695 100644 --- a/apps/metrics.go +++ b/apps/metrics.go @@ -14,6 +14,7 @@ type Metrics struct { Odoo prometheus.GaugeVec Postgres prometheus.GaugeVec Vaultwarden prometheus.GaugeVec + Version prometheus.GaugeVec } func NewMetrics(reg prometheus.Registerer) *Metrics { @@ -27,6 +28,7 @@ func NewMetrics(reg prometheus.Registerer) *Metrics { Odoo: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "odoo", Help: ""}, []string{"version", "version_date"}), Postgres: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "postgres", Help: ""}, []string{"version"}), Vaultwarden: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "vaultwarden", Help: ""}, []string{"version"}), + Version: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "appexporter", Name: "version", Help: "The version of this exporter"}, []string{"version"}), } reg.MustRegister( @@ -39,6 +41,7 @@ func NewMetrics(reg prometheus.Registerer) *Metrics { metrics.Odoo, metrics.Postgres, metrics.Vaultwarden, + metrics.Version, ) return metrics @@ -46,6 +49,8 @@ func NewMetrics(reg prometheus.Registerer) *Metrics { // Reset all metrics // +// Reset all except app-exporter version +// // This should be called on every loop iteration. func (m *Metrics) Reset() { m.Cubebackup.Reset()