Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit a4c7ffa

Browse files
committed
PG "Alert template" dash: replace "Available connections" with
"Instance connections used %" as looking at per DB connections does not give the whole picture. Needs "settings" metric also activated though.
1 parent 49e426a commit a4c7ffa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

grafana_dashboards/postgres/v6/alert-template/dashboard.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"dashes": false,
160160
"datasource": null,
161161
"decimals": 0,
162-
"description": "max_connections - used",
162+
"description": "100.0 * connections / max_connections",
163163
"fill": 1,
164164
"fillGradient": 0,
165165
"gridPos": {
@@ -217,7 +217,7 @@
217217
"orderByTime": "ASC",
218218
"policy": "default",
219219
"rawQuery": true,
220-
"rawSql": "SELECT\n $__timeGroup(time, $__interval),\n dbname,\n avg((select (data->'max_connections')::int from settings where time > now() - '6h'::interval order by time desc limit 1) - (select (data->'numbackends')::int)) as is_primary\nFROM\n db_stats\nWHERE\n $__timeFilter(time)\nGROUP BY 1, 2\nORDER BY 1, 2\n",
220+
"rawSql": "SELECT\n time,\n dbname,\n /* NB! the selected $__timeFilter should be greater than the 'settings' metric's interval, i.e. 2h+ when using some default preset config */\n 100.0 * max_total_sessions / (select coalesce((data->'max_connections')::int, 1) from settings where dbname = x.dbname and $__timeFilter(time) order by time desc limit 1) as pct_used\nFROM (\nSELECT\n $__timeGroup(time, $__interval),\n dbname,\n max((data->'instance_total')::int) as max_total_sessions\nFROM\n backends\nWHERE\n $__timeFilter(time)\nGROUP BY 1, 2\nORDER BY 1, 2\n) x\nORDER BY 1, 2\n",
221221
"refId": "A",
222222
"resultFormat": "time_series",
223223
"select": [
@@ -249,10 +249,10 @@
249249
"timeFrom": null,
250250
"timeRegions": [],
251251
"timeShift": null,
252-
"title": "Available connections < 10",
252+
"title": "Instance connections used %",
253253
"tooltip": {
254254
"shared": true,
255-
"sort": 0,
255+
"sort": 2,
256256
"value_type": "individual"
257257
},
258258
"type": "graph",
@@ -266,7 +266,7 @@
266266
"yaxes": [
267267
{
268268
"decimals": 0,
269-
"format": "short",
269+
"format": "percent",
270270
"label": null,
271271
"logBase": 1,
272272
"max": null,

0 commit comments

Comments
 (0)