File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
This CHANGELOG follows the format listed at [ Keep A Changelog] ( http://keepachangelog.com/ )
5
5
6
6
## [ Unreleased]
7
+ ### Fixed
8
+ - metric-postgres-connections: Handle postgres version 9.6 and above.
9
+
7
10
### Changed
8
11
- Updated all the scripts to add an optional timeout setting.
9
12
Original file line number Diff line number Diff line change @@ -81,8 +81,17 @@ def run
81
81
password : config [ :password ] ,
82
82
connect_timeout : config [ :timeout ] )
83
83
request = [
84
- 'select count(*), waiting from pg_stat_activity' ,
85
- "where datname = '#{ config [ :database ] } ' group by waiting"
84
+ "select case when count(*) = 1 then 'waiting' else" ,
85
+ "'case when wait_event_type is null then false else true end' end as wait_col" ,
86
+ 'from information_schema.columns' ,
87
+ "where table_name = 'pg_stat_activity' and table_schema = 'pg_catalog'" ,
88
+ "and column_name = 'waiting'"
89
+ ]
90
+ wait_col = con . exec ( request . join ( ' ' ) ) . first [ 'wait_col' ]
91
+
92
+ request = [
93
+ "select count(*), #{ wait_col } as waiting from pg_stat_activity" ,
94
+ "where datname = '#{ config [ :database ] } ' group by #{ wait_col } "
86
95
]
87
96
88
97
metrics = {
You can’t perform that action at this time.
0 commit comments