app-exporter/apps/postgres.go

22 lines
397 B
Go
Raw Permalink Normal View History

2024-10-31 20:42:28 +01:00
package apps
import (
"log"
"os/exec"
"strings"
"github.com/prometheus/client_golang/prometheus"
)
func Postgres(m Metrics) {
out, err := exec.Command("psql", "--version").Output()
if err != nil {
log.Printf(">> WARN: Unable to get Postgres version: %v", err)
return
}
version := strings.Split(string(out), " ")[2]
m.Postgres.With(prometheus.Labels{"version": version}).Set(1)
}