mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-09 18:51:25 +00:00
feat: add wait/backend to pg_stat_activity (#1106)
Signed-off-by: Felipe Galindo Sanchez <felipe.galindo.sanchez@intel.com>
This commit is contained in:
parent
9e42fc0145
commit
2ee2a8fa7c
cmd/postgres_exporter
@ -251,6 +251,9 @@ var builtinMetricMaps = map[string]intermediateMetricMap{
|
||||
"state": {LABEL, "connection state", nil, semver.MustParseRange(">=9.2.0")},
|
||||
"usename": {LABEL, "connection usename", nil, nil},
|
||||
"application_name": {LABEL, "connection application_name", nil, nil},
|
||||
"backend_type": {LABEL, "connection backend_type", nil, nil},
|
||||
"wait_event_type": {LABEL, "connection wait_event_type", nil, nil},
|
||||
"wait_event": {LABEL, "connection wait_event", nil, nil},
|
||||
"count": {GAUGE, "number of connections in this state", nil, nil},
|
||||
"max_tx_duration": {GAUGE, "max duration in seconds any active transaction has been running", nil, nil},
|
||||
},
|
||||
|
@ -115,6 +115,9 @@ var queryOverrides = map[string][]OverrideQuery{
|
||||
tmp.state,
|
||||
tmp2.usename,
|
||||
tmp2.application_name,
|
||||
tmp2.backend_type,
|
||||
tmp2.wait_event_type,
|
||||
tmp2.wait_event,
|
||||
COALESCE(count,0) as count,
|
||||
COALESCE(max_tx_duration,0) as max_tx_duration
|
||||
FROM
|
||||
@ -133,9 +136,13 @@ var queryOverrides = map[string][]OverrideQuery{
|
||||
state,
|
||||
usename,
|
||||
application_name,
|
||||
backend_type,
|
||||
wait_event_type,
|
||||
wait_event,
|
||||
count(*) AS count,
|
||||
MAX(EXTRACT(EPOCH FROM now() - xact_start))::float AS max_tx_duration
|
||||
FROM pg_stat_activity GROUP BY datname,state,usename,application_name) AS tmp2
|
||||
FROM pg_stat_activity
|
||||
GROUP BY datname,state,usename,application_name,backend_type,wait_event_type,wait_event) AS tmp2
|
||||
ON tmp.state = tmp2.state AND pg_database.datname = tmp2.datname
|
||||
`,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user