Skip to content

Commit 1decfce

Browse files
authored
[-] fix JSONB null casting errors in postgres/v11 dashboards (#838)
1 parent 78b7e98 commit 1decfce

27 files changed

+143
-143
lines changed

grafana/postgres/v11/1-global-db-overview.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@
490490
"policy": "default",
491491
"query": "select sum(diff) from (SELECT last(\"size_b\") - first(\"size_b\") as diff FROM \"db_size\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time(3650d) fill(none))",
492492
"rawQuery": true,
493-
"rawSql": "select\n time,\n sum(last_db_size) as total_size\nfrom (\nselect\n time,\n dbname,\n max(last_value) as last_db_size\nfrom (\n select\n date_trunc('hour', time) as time,\n dbname,\n last_value((data->'size_b')::int8) over w\n from\n db_size\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n window w as (\n partition by dbname, date_trunc('hour', time) order by time rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n )\n) x\ngroup by 1, 2\n) y\ngroup by 1\norder by 1",
493+
"rawSql": "select\n time,\n sum(last_db_size) as total_size\nfrom (\nselect\n time,\n dbname,\n max(last_value) as last_db_size\nfrom (\n select\n date_trunc('hour', time) as time,\n dbname,\n last_value((data->>'size_b')::int8) over w\n from\n db_size\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n window w as (\n partition by dbname, date_trunc('hour', time) order by time rows BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING\n )\n) x\ngroup by 1, 2\n) y\ngroup by 1\norder by 1",
494494
"refId": "A",
495495
"resultFormat": "time_series",
496496
"select": [
@@ -616,7 +616,7 @@
616616
"policy": "default",
617617
"query": "select sum(bloat) from (SELECT last(\"approx_free_space_b\") - first(\"approx_free_space_b\") as bloat FROM \"table_bloat_approx_summary\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time(3650d) fill(none))",
618618
"rawQuery": true,
619-
"rawSql": "select\n $__unixEpochFrom() as time,\n sum(bloat) from\n(\n\n select distinct on (dbname)\n dbname,\n time,\n (data->'approx_table_bloat_b')::int8 as bloat\n from\n table_bloat_approx_summary_sql\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n order by\n dbname, time\n\n) a \n\nunion all\n\nselect\n $__unixEpochTo() as time,\n sum(bloat)\nfrom (\n\n select distinct on (dbname)\n dbname,\n time,\n (data->'approx_table_bloat_b')::int8 as bloat\n from\n table_bloat_approx_summary_sql\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n order by\n dbname, time desc\n \n) b",
619+
"rawSql": "select\n $__unixEpochFrom() as time,\n sum(bloat) from\n(\n\n select distinct on (dbname)\n dbname,\n time,\n (data->>'approx_table_bloat_b')::int8 as bloat\n from\n table_bloat_approx_summary_sql\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n order by\n dbname, time\n\n) a \n\nunion all\n\nselect\n $__unixEpochTo() as time,\n sum(bloat)\nfrom (\n\n select distinct on (dbname)\n dbname,\n time,\n (data->>'approx_table_bloat_b')::int8 as bloat\n from\n table_bloat_approx_summary_sql\n where \n dbname in ($dbname)\n and $__timeFilter(time)\n order by\n dbname, time desc\n \n) b",
620620
"refId": "A",
621621
"resultFormat": "time_series",
622622
"select": [
@@ -730,7 +730,7 @@
730730
"group": [],
731731
"metricColumn": "none",
732732
"rawQuery": true,
733-
"rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->'load_5min')::float8)\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1\nORDER BY 1\n",
733+
"rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->>'load_5min')::float8)\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1\nORDER BY 1\n",
734734
"refId": "A",
735735
"select": [
736736
[
@@ -908,7 +908,7 @@
908908
"policy": "default",
909909
"query": "select non_negative_derivative(mean(\"xact_commit\")) + non_negative_derivative(mean(\"xact_rollback\")) from \"db_stats\" WHERE \"dbname\" =~ /^$dbname/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)",
910910
"rawQuery": true,
911-
"rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->'xact_commit')::int8 as c, lag((data->'xact_commit')::int8) over w as c_lag,\n (data->'xact_rollback')::int8 as r, lag((data->'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1, 2\norder by 1\n",
911+
"rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg(((c - c_lag) + (r - r_lag)) / extract(epoch from time - time_lag)) as \"TPS\"\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, lag(time) over w as time_lag, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag and time > time_lag\ngroup by 1, 2\norder by 1\n",
912912
"refId": "A",
913913
"resultFormat": "time_series",
914914
"select": [
@@ -1457,7 +1457,7 @@
14571457
"policy": "default",
14581458
"query": "SELECT (non_negative_derivative(mean(\"xact_rollback\")) / (non_negative_derivative(mean(\"xact_commit\")) + non_negative_derivative(mean(\"xact_rollback\"))) * 100) FROM \"db_stats\" WHERE $timeFilter GROUP BY dbname, time($__interval) fill(none)",
14591459
"rawQuery": true,
1460-
"rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg(case when c = c_lag and r = r_lag then 0 else (((r - r_lag)::numeric * 100) / ((c - c_lag) + (r - r_lag)) ) end) as tx_err_ratio\nfrom (\n select \n (data->'xact_commit')::int8 as c, lag((data->'xact_commit')::int8) over w as c_lag,\n (data->'xact_rollback')::int8 as r, lag((data->'xact_rollback')::int8) over w as r_lag,\n time, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag\ngroup by 1, 2\norder by 1, 2",
1460+
"rawSql": "select\n $__timeGroup(time, $agg_interval),\n dbname,\n avg(case when c = c_lag and r = r_lag then 0 else (((r - r_lag)::numeric * 100) / ((c - c_lag) + (r - r_lag)) ) end) as tx_err_ratio\nfrom (\n select \n (data->>'xact_commit')::int8 as c, lag((data->>'xact_commit')::int8) over w as c_lag,\n (data->>'xact_rollback')::int8 as r, lag((data->>'xact_rollback')::int8) over w as r_lag,\n time, dbname\n from db_stats\n where dbname in ($dbname) and $__timeFilter(time)\n window w as (partition by dbname order by time) \n) x\nwhere c >= c_lag and r >= r_lag\ngroup by 1, 2\norder by 1, 2",
14611461
"refId": "B",
14621462
"resultFormat": "time_series",
14631463
"select": [
@@ -1640,7 +1640,7 @@
16401640
"policy": "default",
16411641
"query": "SELECT last(\"size_b\") FROM \"db_size\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)",
16421642
"rawQuery": true,
1643-
"rawSql": "select\n $__timeGroup(time, $agg_interval) as time,\n dbname,\n avg((data->'size_b')::int8) db_size\nfrom\n db_size\nwhere \n dbname in ($dbname)\n and $__timeFilter(time)\ngroup by\n 1, 2\norder by\n 1, 2",
1643+
"rawSql": "select\n $__timeGroup(time, $agg_interval) as time,\n dbname,\n avg((data->>'size_b')::int8) db_size\nfrom\n db_size\nwhere \n dbname in ($dbname)\n and $__timeFilter(time)\ngroup by\n 1, 2\norder by\n 1, 2",
16441644
"refId": "A",
16451645
"resultFormat": "time_series",
16461646
"select": [
@@ -1838,7 +1838,7 @@
18381838
"policy": "default",
18391839
"query": "",
18401840
"rawQuery": true,
1841-
"rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((data->'load_5min')::float8)\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2\n",
1841+
"rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((data->>'load_5min')::float8)\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname in ($dbname)\nGROUP BY 1, 2\nORDER BY 1, 2\n",
18421842
"refId": "A",
18431843
"resultFormat": "time_series",
18441844
"select": [
@@ -2574,7 +2574,7 @@
25742574
"policy": "default",
25752575
"query": "SELECT mean(\"idleintransaction\") + mean(\"waiting\") + mean(\"active\") FROM \"backends\" WHERE \"dbname\" =~ /^$dbname$/ AND $timeFilter GROUP BY dbname, time($__interval) fill(none)",
25762576
"rawQuery": true,
2577-
"rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((data->'idleintransaction')::int + (data->'waiting')::int + (data->'active')::int) as sessions\nFROM\n backends\nWHERE\n $__timeFilter(time)\n and dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n",
2577+
"rawSql": "SELECT\n $__timeGroup(time, $agg_interval),\n dbname,\n avg((data->>'idleintransaction')::int + (data->>'waiting')::int + (data->>'active')::int) as sessions\nFROM\n backends\nWHERE\n $__timeFilter(time)\n and dbname in ($dbname)\nGROUP BY\n 1, 2\nORDER BY\n 1, 2\n",
25782578
"refId": "A",
25792579
"resultFormat": "time_series",
25802580
"select": [
@@ -2694,13 +2694,13 @@
26942694
"type": "grafana-postgresql-datasource",
26952695
"uid": "pgwatch-metrics"
26962696
},
2697-
"definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics a WHERE case when '$current_primaries_only' = 'yes' then (select (data->'in_recovery_int')::int as in_recovery_int from db_stats where dbname = a.dbname and time > now() - '1h'::interval order by time desc limit 1) = 0 else true end ORDER BY 1;",
2697+
"definition": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics a WHERE case when '$current_primaries_only' = 'yes' then (select (data->>'in_recovery_int')::int as in_recovery_int from db_stats where dbname = a.dbname and time > now() - '1h'::interval order by time desc limit 1) = 0 else true end ORDER BY 1;",
26982698
"hide": 0,
26992699
"includeAll": true,
27002700
"multi": true,
27012701
"name": "dbname",
27022702
"options": [],
2703-
"query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics a WHERE case when '$current_primaries_only' = 'yes' then (select (data->'in_recovery_int')::int as in_recovery_int from db_stats where dbname = a.dbname and time > now() - '1h'::interval order by time desc limit 1) = 0 else true end ORDER BY 1;",
2703+
"query": "SELECT DISTINCT dbname FROM admin.all_distinct_dbname_metrics a WHERE case when '$current_primaries_only' = 'yes' then (select (data->>'in_recovery_int')::int as in_recovery_int from db_stats where dbname = a.dbname and time > now() - '1h'::interval order by time desc limit 1) = 0 else true end ORDER BY 1;",
27042704
"refresh": 1,
27052705
"regex": "",
27062706
"skipUrlSync": false,

grafana/postgres/v11/biggest-relations.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"orderByTime": "ASC",
9898
"policy": "default",
9999
"rawQuery": true,
100-
"rawSql": "SELECT\n time,\n (data->'total_relation_size_b')::int8 as total_relation_size_b,\n tag_data->>'table_full_name'::text as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100",
100+
"rawSql": "SELECT\n time,\n (data->>'total_relation_size_b')::int8 as total_relation_size_b,\n tag_data->>'table_full_name'::text as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100",
101101
"refId": "A",
102102
"resultFormat": "time_series",
103103
"select": [
@@ -202,7 +202,7 @@
202202
"orderByTime": "ASC",
203203
"policy": "default",
204204
"rawQuery": true,
205-
"rawSql": "SELECT\n 0 as time,\n (data->'table_size_b')::int8 + coalesce((data->'toast_size_b')::int8, 0) as table_size_b,\n tag_data->>'table_full_name' as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100",
205+
"rawSql": "SELECT\n 0 as time,\n (data->>'table_size_b')::int8 + coalesce((data->>'toast_size_b')::int8, 0) as table_size_b,\n tag_data->>'table_full_name' as table_name\nFROM\n table_stats\nWHERE\n time = (select max(time) from table_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100",
206206
"refId": "A",
207207
"resultFormat": "time_series",
208208
"select": [
@@ -306,7 +306,7 @@
306306
"orderByTime": "ASC",
307307
"policy": "default",
308308
"rawQuery": true,
309-
"rawSql": "SELECT\n 0 as time,\n (data->'index_size_b')::int8 as index_size_b,\n tag_data->>'index_full_name' as index_full_name\nFROM\n index_stats\nWHERE\n time = (select max(time) from index_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100",
309+
"rawSql": "SELECT\n 0 as time,\n (data->>'index_size_b')::int8 as index_size_b,\n tag_data->>'index_full_name' as index_full_name\nFROM\n index_stats\nWHERE\n time = (select max(time) from index_stats WHERE dbname = '$dbname' AND $__timeFilter(time))\n AND dbname = '$dbname'\nORDER BY\n 2 DESC NULLS LAST\nLIMIT 100",
310310
"refId": "A",
311311
"resultFormat": "time_series",
312312
"select": [

grafana/postgres/v11/change-events.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
"policy": "default",
198198
"query": "",
199199
"rawQuery": true,
200-
"rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->'load_5min')::float8) as \"load_5min\"\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1",
200+
"rawSql": "SELECT\n $__timeGroup(time, $__interval),\n avg((data->>'load_5min')::float8) as \"load_5min\"\nFROM\n cpu_load\nWHERE\n $__timeFilter(time)\n AND dbname = '$dbname'\nGROUP BY 1\nORDER BY 1",
201201
"refId": "A",
202202
"resultFormat": "time_series",
203203
"select": [
@@ -249,7 +249,7 @@
249249
"orderByTime": "ASC",
250250
"policy": "default",
251251
"rawQuery": true,
252-
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg( case when (xc = xc_lag and xr = xr_lag) then null else ( ((xr - xr_lag)::numeric*100) / ((xc - xc_lag) + (xr - xr_lag)) ) end ) as \"Rollback ratio\"\nfrom (\n select\n (data->'xact_rollback')::float8 as xr, lag((data->'xact_rollback')::float8) over w as xr_lag,\n (data->'xact_commit')::float8 as xc, lag((data->'xact_rollback')::float8) over w as xc_lag,\n time\n from db_stats\n where dbname = '$dbname'\n and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere xc >= xc_lag\ngroup by 1\norder by 1\n\n\n\n\n\n",
252+
"rawSql": "select\n $__timeGroup(time, $__interval),\n avg( case when (xc = xc_lag and xr = xr_lag) then null else ( ((xr - xr_lag)::numeric*100) / ((xc - xc_lag) + (xr - xr_lag)) ) end ) as \"Rollback ratio\"\nfrom (\n select\n (data->>'xact_rollback')::float8 as xr, lag((data->>'xact_rollback')::float8) over w as xr_lag,\n (data->>'xact_commit')::float8 as xc, lag((data->>'xact_rollback')::float8) over w as xc_lag,\n time\n from db_stats\n where dbname = '$dbname'\n and $__timeFilter(time)\n window w as (order by time)\n) x\nwhere xc >= xc_lag\ngroup by 1\norder by 1\n\n\n\n\n\n",
253253
"refId": "B",
254254
"resultFormat": "time_series",
255255
"select": [

0 commit comments

Comments
 (0)