Skip to content

Commit 6859e01

Browse files
slardiereSébastien Lardière0xgouda
authored
[-] fix quoting $databases var in pgbouncer dashboard (#1349)
* Fix quoting databases name with the default use of the $databases variable in Grafana, the quoting is wrong when there is only one DB selected by the user. * Use `sqlstring` formatter instead of `singlquote` --------- Co-authored-by: Sébastien Lardière <s.lardiere@loxodata.com> Co-authored-by: Ahmed Gouda <gouda0x@gmail.com>
1 parent 776cdd5 commit 6859e01

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

grafana/postgres/v12/pgbouncer-stats.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
"policy": "default",
120120
"query": "",
121121
"rawQuery": true,
122-
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
122+
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
123123
"refId": "A",
124124
"resultFormat": "time_series",
125125
"select": [
@@ -261,7 +261,7 @@
261261
"policy": "default",
262262
"query": "",
263263
"rawQuery": true,
264-
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
264+
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
265265
"refId": "A",
266266
"resultFormat": "time_series",
267267
"select": [
@@ -401,7 +401,7 @@
401401
"orderByTime": "ASC",
402402
"policy": "default",
403403
"rawQuery": true,
404-
"rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
404+
"rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
405405
"refId": "A",
406406
"resultFormat": "time_series",
407407
"select": [
@@ -530,7 +530,7 @@
530530
"orderByTime": "ASC",
531531
"policy": "default",
532532
"rawQuery": true,
533-
"rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
533+
"rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag))\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
534534
"refId": "A",
535535
"resultFormat": "time_series",
536536
"select": [
@@ -671,7 +671,7 @@
671671
"orderByTime": "ASC",
672672
"policy": "default",
673673
"rawQuery": true,
674-
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
674+
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
675675
"refId": "A",
676676
"resultFormat": "time_series",
677677
"select": [
@@ -811,7 +811,7 @@
811811
"orderByTime": "ASC",
812812
"policy": "default",
813813
"rawQuery": true,
814-
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
814+
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg((c - c_lag) / extract(epoch from time - time_lag)) as tps\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
815815
"refId": "A",
816816
"resultFormat": "time_series",
817817
"select": [
@@ -985,7 +985,7 @@
985985
"orderByTime": "ASC",
986986
"policy": "default",
987987
"rawQuery": true,
988-
"rawSql": "select\n $__timeGroup(time, $__interval), \n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
988+
"rawSql": "select\n $__timeGroup(time, $__interval), \n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'total_xact_count')::int8 as c, lag((data->>'total_xact_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
989989
"refId": "A",
990990
"resultFormat": "time_series",
991991
"select": [
@@ -1190,7 +1190,7 @@
11901190
"orderByTime": "ASC",
11911191
"policy": "default",
11921192
"rawQuery": true,
1193-
"rawSql": "select\n$__timeGroup(time, $__interval),\ndatabase,\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Pool wait time\"\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1",
1193+
"rawSql": "select\n$__timeGroup(time, $__interval),\ndatabase,\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Pool wait time\"\n\nfrom (\n\n select \n (data->>'total_wait_time')::float8 as tt, lag((data->>'total_wait_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1",
11941194
"refId": "A",
11951195
"resultFormat": "time_series",
11961196
"select": [
@@ -1412,7 +1412,7 @@
14121412
"orderByTime": "ASC",
14131413
"policy": "default",
14141414
"rawQuery": true,
1415-
"rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
1415+
"rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"QPS\"\nfrom (\n select \n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
14161416
"refId": "A",
14171417
"resultFormat": "time_series",
14181418
"select": [
@@ -1639,7 +1639,7 @@
16391639
"orderByTime": "ASC",
16401640
"policy": "default",
16411641
"rawQuery": true,
1642-
"rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Incoming rate\"\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
1642+
"rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Incoming rate\"\nfrom (\n select \n (data->>'total_received')::int8 as c, lag((data->>'total_received')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
16431643
"refId": "A",
16441644
"resultFormat": "time_series",
16451645
"select": [
@@ -1822,7 +1822,7 @@
18221822
"orderByTime": "ASC",
18231823
"policy": "default",
18241824
"rawQuery": true,
1825-
"rawSql": "select\n$__timeGroup(time, $__interval),\ndatabase,\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Avg. runtime\"\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time,\n data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1",
1825+
"rawSql": "select\n$__timeGroup(time, $__interval),\ndatabase,\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Avg. runtime\"\nfrom (\n\n select \n (data->>'total_query_time')::float8 as tt, lag((data->>'total_query_time')::float8) over w as tt_lag,\n (data->>'total_query_count')::int8 as c, lag((data->>'total_query_count')::int8) over w as c_lag,\n time,\n data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1, 2\norder by 1",
18261826
"refId": "A",
18271827
"resultFormat": "time_series",
18281828
"select": [
@@ -2030,7 +2030,7 @@
20302030
"orderByTime": "ASC",
20312031
"policy": "default",
20322032
"rawQuery": true,
2033-
"rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Outgoing rate\"\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in ($databases) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
2033+
"rawSql": "select\n $__timeGroup(time, $__interval),\n database,\n avg((c - c_lag) / extract(epoch from time - time_lag)) as \"Outgoing rate\"\nfrom (\n select \n (data->>'total_sent')::int8 as c, lag((data->>'total_sent')::int8) over w as c_lag,\n time, lag(time) over w as time_lag, data->>'database' as database\n from pgbouncer_stats\n where data->>'database' in (${databases:sqlstring}) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by data->>'database', time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1, 2\norder by 1",
20342034
"refId": "A",
20352035
"resultFormat": "time_series",
20362036
"select": [

0 commit comments

Comments
 (0)