Skip to content

Commit 9d4e5c5

Browse files
[-] fix aggregation of counts in v11 stat-activity dashboard (#1021)
* fix aggregation of query counts * Adjust column sizes and alignments * remove `min_duration_s` variable --------- Co-authored-by: 0xgouda <gouda0x@gmail.com>
1 parent 81b1e27 commit 9d4e5c5

File tree

1 file changed

+27
-23
lines changed

1 file changed

+27
-23
lines changed

grafana/postgres/v11/stat-activity.json

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,36 @@
2121
"links": [],
2222
"panels": [
2323
{
24-
"columns": [],
2524
"datasource": {
2625
"type": "grafana-postgresql-datasource",
2726
"uid": "pgwatch-metrics"
2827
},
2928
"description": "Top 25 longest running queries from pg_stat_activity. Query texts are compacted",
30-
"fontSize": "100%",
29+
"fieldConfig": {
30+
"defaults": {
31+
"custom": {
32+
"align": "left",
33+
"cellOptions": {
34+
"type": "auto"
35+
},
36+
"inspect": false
37+
}
38+
},
39+
"overrides": [
40+
{
41+
"matcher": {
42+
"id": "byName",
43+
"options": "count"
44+
},
45+
"properties": [
46+
{
47+
"id": "custom.width",
48+
"value": 200
49+
}
50+
]
51+
}
52+
]
53+
},
3154
"gridPos": {
3255
"h": 24,
3356
"w": 24,
@@ -132,7 +155,7 @@
132155
"group": [],
133156
"metricColumn": "none",
134157
"rawQuery": true,
135-
"rawSql": "SELECT\n query AS query,\n count(*) AS count\nFROM\n stat_activity\nWHERE\n dbname = '$dbname'\n AND $__timeFilter(time)\nGROUP BY\n query\nORDER BY\n count DESC\nLIMIT 25\n",
158+
"rawSql": "SELECT\n sum((data->>'count')::integer) as count, data->>'query' AS query\n FROM\n stat_activity\nWHERE\n dbname = '$dbname'\n AND $__timeFilter(time)\nGROUP BY\n query\nORDER BY\n count DESC\nLIMIT 25\n",
136159
"refId": "A",
137160
"select": [
138161
[
@@ -155,8 +178,7 @@
155178
}
156179
],
157180
"title": "Stat Activity",
158-
"transform": "table",
159-
"type": "table-old"
181+
"type": "table"
160182
}
161183
],
162184
"refresh": "5s",
@@ -192,24 +214,6 @@
192214
"tagsQuery": "",
193215
"type": "query",
194216
"useTags": false
195-
},
196-
{
197-
"current": {
198-
"text": "1",
199-
"value": "1"
200-
},
201-
"hide": 0,
202-
"name": "min_duration_s",
203-
"options": [
204-
{
205-
"selected": true,
206-
"text": "1",
207-
"value": "1"
208-
}
209-
],
210-
"query": "1",
211-
"skipUrlSync": false,
212-
"type": "textbox"
213217
}
214218
]
215219
},

0 commit comments

Comments
 (0)