app-exporter/apps/postgres.go

21 lines
402 B
Go

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