From b0cf387655d94b069a29e00dece42543883fd6ea Mon Sep 17 00:00:00 2001 From: Valentin Doreau Date: Sat, 2 Nov 2024 19:11:59 +0100 Subject: [PATCH] refactor: prefer pg_config in place of psql for postgres version --- apps/postgres.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/postgres.go b/apps/postgres.go index 6046eb5..3a007cb 100644 --- a/apps/postgres.go +++ b/apps/postgres.go @@ -9,13 +9,13 @@ import ( ) func Postgres(m Metrics) { - out, err := exec.Command("psql", "--version").Output() + 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), " ")[2] + version := strings.Split(string(out), " ")[1] m.Postgres.With(prometheus.Labels{"version": version}).Set(1) }