mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-04-07 17:51:33 +00:00
add changes for transaction duration to determine stage change
This commit is contained in:
parent
cf49216b12
commit
25e8f0bca1
@ -258,12 +258,13 @@ var builtinMetricMaps = map[string]intermediateMetricMap{
|
||||
},
|
||||
"pg_stat_activity": {
|
||||
map[string]ColumnMapping{
|
||||
"datname": {LABEL, "Name of this database", nil, nil},
|
||||
"state": {LABEL, "connection state", nil, semver.MustParseRange(">=9.2.0")},
|
||||
"usename": {LABEL, "Name of the user logged into this backend", nil, nil},
|
||||
"application_name": {LABEL, "Name of the application that is connected to this backend", 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},
|
||||
"datname": {LABEL, "Name of this database", nil, nil},
|
||||
"state": {LABEL, "connection state", nil, semver.MustParseRange(">=9.2.0")},
|
||||
"usename": {LABEL, "Name of the user logged into this backend", nil, nil},
|
||||
"application_name": {LABEL, "Name of the application that is connected to this backend", 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},
|
||||
"max_state_duration": {GAUGE, "max state change duration in seconds any active transaction has been", nil, nil},
|
||||
},
|
||||
true,
|
||||
0,
|
||||
|
@ -131,7 +131,8 @@ var queryOverrides = map[string][]OverrideQuery{
|
||||
tmp2.usename,
|
||||
tmp2.application_name,
|
||||
COALESCE(count,0) as count,
|
||||
COALESCE(max_tx_duration,0) as max_tx_duration
|
||||
COALESCE(max_tx_duration,0) as max_tx_duration,
|
||||
COALESCE(max_state_duration, 0) AS max_state_duration
|
||||
FROM
|
||||
(
|
||||
VALUES ('active'),
|
||||
@ -149,7 +150,8 @@ var queryOverrides = map[string][]OverrideQuery{
|
||||
usename,
|
||||
application_name,
|
||||
count(*) AS count,
|
||||
MAX(EXTRACT(EPOCH FROM now() - xact_start))::float AS max_tx_duration
|
||||
MAX(EXTRACT(EPOCH FROM now() - xact_start))::float AS max_tx_duration,
|
||||
MAX(EXTRACT(EPOCH FROM now() - state_change))::float AS max_state_duration
|
||||
FROM pg_stat_activity GROUP BY datname,state,usename,application_name) AS tmp2
|
||||
ON tmp.state = tmp2.state AND pg_database.datname = tmp2.datname
|
||||
`,
|
||||
@ -163,7 +165,8 @@ var queryOverrides = map[string][]OverrideQuery{
|
||||
usename,
|
||||
application_name,
|
||||
COALESCE(count(*),0) AS count,
|
||||
COALESCE(MAX(EXTRACT(EPOCH FROM now() - xact_start))::float,0) AS max_tx_duration
|
||||
COALESCE(MAX(EXTRACT(EPOCH FROM now() - xact_start))::float,0) AS max_tx_duration,
|
||||
COALESCE(MAX(EXTRACT(EPOCH FROM now() - state_change))::float,0) AS max_state_duration
|
||||
FROM pg_stat_activity GROUP BY datname,usename,application_name
|
||||
`,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user