feat: also export app-exporter version
All checks were successful
Build package / typos (push) Successful in 1m22s

This commit is contained in:
Valentin Doreau 2024-11-15 16:47:30 +01:00
parent f0f1213dbc
commit 6136e08bbd
Signed by: vdoreau
GPG key ID: F3E456CF9A14098B
2 changed files with 8 additions and 0 deletions

View file

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

View file

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