From 763159e1d22e1274ab95717ea307d7437401912c Mon Sep 17 00:00:00 2001 From: tshohe Date: Tue, 17 Jul 2018 00:18:08 +0900 Subject: [PATCH] add query for v9.1 (#203) --- cmd/postgres_exporter/postgres_exporter.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/postgres_exporter/postgres_exporter.go b/cmd/postgres_exporter/postgres_exporter.go index ee6a15f1..9e71f3b6 100644 --- a/cmd/postgres_exporter/postgres_exporter.go +++ b/cmd/postgres_exporter/postgres_exporter.go @@ -338,7 +338,17 @@ var queryOverrides = map[string][]OverrideQuery{ ON tmp.state = tmp2.state AND pg_database.datname = tmp2.datname `, }, - // No query is applicable for 9.1 that gives any sensible data. + { + semver.MustParseRange("<9.2.0"), + ` + SELECT + datname, + 'unknown' AS state, + COALESCE(count(*),0) AS count, + COALESCE(MAX(EXTRACT(EPOCH FROM now() - xact_start))::float,0) AS max_tx_duration + FROM pg_stat_activity GROUP BY datname + `, + }, }, }