From f0f1213dbc98efee3e90dcb462d306165e191376 Mon Sep 17 00:00:00 2001 From: Valentin Doreau Date: Fri, 15 Nov 2024 14:20:05 +0100 Subject: [PATCH] feat: added minio version export --- README.md | 1 + app_exporter.go | 1 + apps/metrics.go | 4 ++++ apps/minio.go | 21 +++++++++++++++++++++ 4 files changed, 27 insertions(+) create mode 100644 apps/minio.go diff --git a/README.md b/README.md index c2ab1ed..d50de8e 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ This is mainly targeted at the Recycled Cloud hosted applications. - forgejo - forgejo_runner - grafana +- minio - nextcloud: `curl -s https://files.rccd:9000/status.php | jq .version -r` - odoo - odoo enterprise commit/date: TODO diff --git a/app_exporter.go b/app_exporter.go index 44875ff..afb81fe 100644 --- a/app_exporter.go +++ b/app_exporter.go @@ -62,6 +62,7 @@ func RecordMetrics(m apps.Metrics) { apps.Forgejo(m) apps.ForgejoRunner(m) apps.Grafana(m) + apps.Minio(m) apps.Nextcloud(m) apps.Odoo(m) apps.Postgres(m) diff --git a/apps/metrics.go b/apps/metrics.go index fd2ec76..1e19230 100644 --- a/apps/metrics.go +++ b/apps/metrics.go @@ -9,6 +9,7 @@ type Metrics struct { Forgejo prometheus.GaugeVec ForgejoRunner prometheus.GaugeVec Grafana prometheus.GaugeVec + Minio prometheus.GaugeVec Nextcloud prometheus.GaugeVec Odoo prometheus.GaugeVec Postgres prometheus.GaugeVec @@ -21,6 +22,7 @@ func NewMetrics(reg prometheus.Registerer) *Metrics { 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"}), + Minio: *prometheus.NewGaugeVec(prometheus.GaugeOpts{Namespace: "app", Subsystem: "version", Name: "minio", 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"}), @@ -32,6 +34,7 @@ func NewMetrics(reg prometheus.Registerer) *Metrics { metrics.Forgejo, metrics.ForgejoRunner, metrics.Grafana, + metrics.Minio, metrics.Nextcloud, metrics.Odoo, metrics.Postgres, @@ -49,6 +52,7 @@ func (m *Metrics) Reset() { m.Forgejo.Reset() m.ForgejoRunner.Reset() m.Grafana.Reset() + m.Minio.Reset() m.Nextcloud.Reset() m.Odoo.Reset() m.Postgres.Reset() diff --git a/apps/minio.go b/apps/minio.go new file mode 100644 index 0000000..ee01823 --- /dev/null +++ b/apps/minio.go @@ -0,0 +1,21 @@ +package apps + +import ( + "log" + "os/exec" + "strings" + + "github.com/prometheus/client_golang/prometheus" +) + +func Minio(m Metrics) { + out, err := exec.Command("minio", "--version").Output() + if err != nil { + log.Printf(">> WARN: Unable to get Minio version: %v", err) + return + } + + version := strings.Split(string(out), " ")[2] + + m.Minio.With(prometheus.Labels{"version": version}).Set(1) +}