2024-10-31 20:42:28 +01:00
|
|
|
package apps
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Metrics struct {
|
|
|
|
Cubebackup prometheus.GaugeVec
|
|
|
|
Forgejo prometheus.GaugeVec
|
|
|
|
ForgejoRunner prometheus.GaugeVec
|
|
|
|
Grafana prometheus.GaugeVec
|
2024-11-15 14:20:05 +01:00
|
|
|
Minio prometheus.GaugeVec
|
2024-10-31 20:42:28 +01:00
|
|
|
Nextcloud prometheus.GaugeVec
|
|
|
|
Odoo prometheus.GaugeVec
|
|
|
|
Postgres prometheus.GaugeVec
|
|
|
|
Vaultwarden prometheus.GaugeVec
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMetrics(reg prometheus.Registerer) *Metrics {
|
|
|
|
metrics := &Metrics{
|
|
|
|
Cubebackup: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "cubebackup", Help: ""}, []string{"version"}),
|
|
|
|
Forgejo: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "forgejo", Help: ""}, []string{"version"}),
|
|
|
|
ForgejoRunner: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "forgejo_runner", Help: ""}, []string{"version"}),
|
|
|
|
Grafana: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "grafana", Help: ""}, []string{"version"}),
|
2024-11-15 14:20:05 +01:00
|
|
|
Minio: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "minio", Help: ""}, []string{"version"}),
|
2024-10-31 20:42:28 +01:00
|
|
|
Nextcloud: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "nextcloud", Help: ""}, []string{"version"}),
|
|
|
|
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"}),
|
|
|
|
}
|
|
|
|
|
|
|
|
reg.MustRegister(
|
|
|
|
metrics.Cubebackup,
|
|
|
|
metrics.Forgejo,
|
|
|
|
metrics.ForgejoRunner,
|
|
|
|
metrics.Grafana,
|
2024-11-15 14:20:05 +01:00
|
|
|
metrics.Minio,
|
2024-10-31 20:42:28 +01:00
|
|
|
metrics.Nextcloud,
|
|
|
|
metrics.Odoo,
|
|
|
|
metrics.Postgres,
|
|
|
|
metrics.Vaultwarden,
|
|
|
|
)
|
|
|
|
|
|
|
|
return metrics
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset all metrics
|
|
|
|
//
|
|
|
|
// This should be called on every loop iteration.
|
|
|
|
func (m *Metrics) Reset() {
|
|
|
|
m.Cubebackup.Reset()
|
|
|
|
m.Forgejo.Reset()
|
|
|
|
m.ForgejoRunner.Reset()
|
|
|
|
m.Grafana.Reset()
|
2024-11-15 14:20:05 +01:00
|
|
|
m.Minio.Reset()
|
2024-10-31 20:42:28 +01:00
|
|
|
m.Nextcloud.Reset()
|
|
|
|
m.Odoo.Reset()
|
|
|
|
m.Postgres.Reset()
|
|
|
|
m.Vaultwarden.Reset()
|
|
|
|
}
|