57 lines
2.1 KiB
Go
57 lines
2.1 KiB
Go
|
package apps
|
||
|
|
||
|
import (
|
||
|
"github.com/prometheus/client_golang/prometheus"
|
||
|
)
|
||
|
|
||
|
type Metrics struct {
|
||
|
Cubebackup prometheus.GaugeVec
|
||
|
Forgejo prometheus.GaugeVec
|
||
|
ForgejoRunner prometheus.GaugeVec
|
||
|
Grafana prometheus.GaugeVec
|
||
|
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"}),
|
||
|
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,
|
||
|
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()
|
||
|
m.Nextcloud.Reset()
|
||
|
m.Odoo.Reset()
|
||
|
m.Postgres.Reset()
|
||
|
m.Vaultwarden.Reset()
|
||
|
}
|