Skip to content

Commit 20845fe

Browse files
committed
Make $dbname a multi-value variable
1 parent 3ed9a00 commit 20845fe

File tree

1 file changed

+50
-23
lines changed

1 file changed

+50
-23
lines changed

grafana/postgres/v12/pgbouncer-stats.json

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@
8888
"wideLayout": true
8989
},
9090
"pluginVersion": "12.0.0",
91+
"repeat": "dbname",
92+
"repeatDirection": "v",
9193
"targets": [
9294
{
9395
"alias": "TPS",
@@ -117,7 +119,7 @@
117119
"policy": "default",
118120
"query": "",
119121
"rawQuery": true,
120-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by 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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
121123
"refId": "A",
122124
"resultFormat": "time_series",
123125
"select": [
@@ -158,7 +160,7 @@
158160
}
159161
],
160162
"timeFrom": "15m",
161-
"title": "TPS",
163+
"title": "TPS - $dbname",
162164
"type": "stat"
163165
},
164166
{
@@ -228,6 +230,8 @@
228230
"wideLayout": true
229231
},
230232
"pluginVersion": "12.0.0",
233+
"repeat": "dbname",
234+
"repeatDirection": "v",
231235
"targets": [
232236
{
233237
"alias": "QPS",
@@ -257,7 +261,7 @@
257261
"policy": "default",
258262
"query": "",
259263
"rawQuery": true,
260-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by 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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
261265
"refId": "A",
262266
"resultFormat": "time_series",
263267
"select": [
@@ -298,7 +302,7 @@
298302
}
299303
],
300304
"timeFrom": "15m",
301-
"title": "QPS",
305+
"title": "QPS - $dbname",
302306
"type": "stat"
303307
},
304308
{
@@ -368,6 +372,8 @@
368372
"wideLayout": true
369373
},
370374
"pluginVersion": "12.0.0",
375+
"repeat": "dbname",
376+
"repeatDirection": "v",
371377
"targets": [
372378
{
373379
"alias": "avg_query_runtime",
@@ -395,7 +401,7 @@
395401
"orderByTime": "ASC",
396402
"policy": "default",
397403
"rawQuery": true,
398-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by 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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
399405
"refId": "A",
400406
"resultFormat": "time_series",
401407
"select": [
@@ -424,7 +430,7 @@
424430
}
425431
],
426432
"timeFrom": "15m",
427-
"title": "Avg. query runtime",
433+
"title": "Avg. query runtime - $dbname",
428434
"type": "stat"
429435
},
430436
{
@@ -494,6 +500,8 @@
494500
"wideLayout": true
495501
},
496502
"pluginVersion": "12.0.0",
503+
"repeat": "dbname",
504+
"repeatDirection": "v",
497505
"targets": [
498506
{
499507
"alias": "db_size_change_last_hour",
@@ -522,7 +530,7 @@
522530
"orderByTime": "ASC",
523531
"policy": "default",
524532
"rawQuery": true,
525-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by 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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
526534
"refId": "A",
527535
"resultFormat": "time_series",
528536
"select": [
@@ -563,7 +571,7 @@
563571
}
564572
],
565573
"timeFrom": "1h",
566-
"title": "Pool wait time",
574+
"title": "Pool wait time - $dbname",
567575
"type": "stat"
568576
},
569577
{
@@ -633,6 +641,8 @@
633641
"wideLayout": true
634642
},
635643
"pluginVersion": "12.0.0",
644+
"repeat": "dbname",
645+
"repeatDirection": "v",
636646
"targets": [
637647
{
638648
"alias": "bytes_received",
@@ -661,7 +671,7 @@
661671
"orderByTime": "ASC",
662672
"policy": "default",
663673
"rawQuery": true,
664-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by 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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
665675
"refId": "A",
666676
"resultFormat": "time_series",
667677
"select": [
@@ -702,7 +712,7 @@
702712
}
703713
],
704714
"timeFrom": "15m",
705-
"title": "Incoming traffic",
715+
"title": "Incoming traffic - $dbname",
706716
"type": "stat"
707717
},
708718
{
@@ -772,6 +782,8 @@
772782
"wideLayout": true
773783
},
774784
"pluginVersion": "12.0.0",
785+
"repeat": "dbname",
786+
"repeatDirection": "v",
775787
"targets": [
776788
{
777789
"datasource": {
@@ -799,7 +811,7 @@
799811
"orderByTime": "ASC",
800812
"policy": "default",
801813
"rawQuery": true,
802-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by 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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
803815
"refId": "A",
804816
"resultFormat": "time_series",
805817
"select": [
@@ -840,7 +852,7 @@
840852
}
841853
],
842854
"timeFrom": "15m",
843-
"title": "Outgoing traffic",
855+
"title": "Outgoing traffic - $dbname",
844856
"type": "stat"
845857
},
846858
{
@@ -945,6 +957,8 @@
945957
}
946958
},
947959
"pluginVersion": "12.0.0",
960+
"repeat": "dbname",
961+
"repeatDirection": "v",
948962
"targets": [
949963
{
950964
"alias": "TPS",
@@ -973,7 +987,7 @@
973987
"orderByTime": "ASC",
974988
"policy": "default",
975989
"rawQuery": true,
976-
"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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
990+
"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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
977991
"refId": "A",
978992
"resultFormat": "time_series",
979993
"select": [
@@ -1013,7 +1027,7 @@
10131027
]
10141028
}
10151029
],
1016-
"title": "TPS",
1030+
"title": "TPS - $dbname",
10171031
"type": "timeseries"
10181032
},
10191033
{
@@ -1132,6 +1146,8 @@
11321146
}
11331147
},
11341148
"pluginVersion": "12.0.0",
1149+
"repeat": "dbname",
1150+
"repeatDirection": "v",
11351151
"targets": [
11361152
{
11371153
"alias": "Pool wait time",
@@ -1161,7 +1177,7 @@
11611177
"orderByTime": "ASC",
11621178
"policy": "default",
11631179
"rawQuery": true,
1164-
"rawSql": "select\n$__timeGroup(time, $__interval),\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\n from pgbouncer_stats\n where data->>'database' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
1180+
"rawSql": "select\n$__timeGroup(time, $__interval),\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\n from pgbouncer_stats\n where data->>'database' in ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
11651181
"refId": "A",
11661182
"resultFormat": "time_series",
11671183
"select": [
@@ -1189,7 +1205,7 @@
11891205
]
11901206
}
11911207
],
1192-
"title": "Pool wait time per Query",
1208+
"title": "Pool wait time per Query - $dbname",
11931209
"type": "timeseries"
11941210
},
11951211
{
@@ -1338,6 +1354,8 @@
13381354
}
13391355
},
13401356
"pluginVersion": "12.0.0",
1357+
"repeat": "dbname",
1358+
"repeatDirection": "v",
13411359
"targets": [
13421360
{
13431361
"alias": "QPS",
@@ -1366,7 +1384,7 @@
13661384
"orderByTime": "ASC",
13671385
"policy": "default",
13681386
"rawQuery": true,
1369-
"rawSql": "select\n $__timeGroup(time, $__interval),\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\n from pgbouncer_stats\n where data->>'database' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
1387+
"rawSql": "select\n $__timeGroup(time, $__interval),\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\n from pgbouncer_stats\n where data->>'database' in ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
13701388
"refId": "A",
13711389
"resultFormat": "time_series",
13721390
"select": [
@@ -1400,7 +1418,7 @@
14001418
]
14011419
}
14021420
],
1403-
"title": "QPS",
1421+
"title": "QPS - $dbname",
14041422
"type": "timeseries"
14051423
},
14061424
{
@@ -1548,6 +1566,8 @@
15481566
}
15491567
},
15501568
"pluginVersion": "12.0.0",
1569+
"repeat": "dbname",
1570+
"repeatDirection": "v",
15511571
"targets": [
15521572
{
15531573
"alias": "Incoming rate",
@@ -1576,7 +1596,7 @@
15761596
"orderByTime": "ASC",
15771597
"policy": "default",
15781598
"rawQuery": true,
1579-
"rawSql": "select\n $__timeGroup(time, $__interval),\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\n from pgbouncer_stats\n where data->>'database' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
1599+
"rawSql": "select\n $__timeGroup(time, $__interval),\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\n from pgbouncer_stats\n where data->>'database' in ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time) \n) x\nwhere c >= c_lag and time > time_lag\ngroup by 1\norder by 1",
15801600
"refId": "A",
15811601
"resultFormat": "time_series",
15821602
"select": [
@@ -1610,7 +1630,7 @@
16101630
]
16111631
}
16121632
],
1613-
"title": "Incoming traffic rate",
1633+
"title": "Incoming traffic rate - $dbname",
16141634
"type": "timeseries"
16151635
},
16161636
{
@@ -1715,6 +1735,8 @@
17151735
}
17161736
},
17171737
"pluginVersion": "12.0.0",
1738+
"repeat": "dbname",
1739+
"repeatDirection": "v",
17181740
"targets": [
17191741
{
17201742
"alias": "Avg. runtime",
@@ -1742,7 +1764,7 @@
17421764
"orderByTime": "ASC",
17431765
"policy": "default",
17441766
"rawQuery": true,
1745-
"rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Avg. runtime\"\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' = '$dbname' and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
1767+
"rawSql": "select\n$__timeGroup(time, $__interval),\navg((tt-tt_lag)::numeric / (c-c_lag)) as \"Avg. runtime\"\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 ($dbname) and dbname = '$monitoredsource' and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere c > c_lag and tt >= tt_lag\ngroup by 1\norder by 1",
17461768
"refId": "A",
17471769
"resultFormat": "time_series",
17481770
"select": [
@@ -1770,7 +1792,7 @@
17701792
]
17711793
}
17721794
],
1773-
"title": "Avg. query runtime",
1795+
"title": "Avg. query runtime - $dbname",
17741796
"type": "timeseries"
17751797
},
17761798
{
@@ -1905,6 +1927,8 @@
19051927
}
19061928
},
19071929
"pluginVersion": "12.0.0",
1930+
"repeat": "dbname",
1931+
"repeatDirection": "v",
19081932
"targets": [
19091933
{
19101934
"alias": "Outgoing rate",
@@ -1967,7 +1991,7 @@
19671991
]
19681992
}
19691993
],
1970-
"title": "Outgoing traffic rate",
1994+
"title": "Outgoing traffic rate - $dbname",
19711995
"type": "timeseries"
19721996
},
19731997
{
@@ -2013,6 +2037,7 @@
20132037
},
20142038
"definition": "select dbname as monitoredsource from admin.all_distinct_dbname_metrics where metric = 'pgbouncer_stats';",
20152039
"name": "monitoredsource",
2040+
"label": "Monitored Source",
20162041
"options": [],
20172042
"query": "select dbname as monitoredsource from admin.all_distinct_dbname_metrics where metric = 'pgbouncer_stats';",
20182043
"refresh": 1,
@@ -2032,7 +2057,9 @@
20322057
},
20332058
"definition": "select distinct (data->>'database') as database from pgbouncer_stats where dbname = '$monitoredsource' ;",
20342059
"includeAll": false,
2060+
"multi": true,
20352061
"name": "dbname",
2062+
"label": "DB Name",
20362063
"options": [],
20372064
"query": "select distinct (data->>'database') as database from pgbouncer_stats where dbname = '$monitoredsource' ;",
20382065
"refresh": 1,

0 commit comments

Comments
 (0)