From 9003ac8f0a3046426f7f829fc61dae566a7068de Mon Sep 17 00:00:00 2001 From: "Ryan J. Geyer" Date: Wed, 25 May 2022 14:32:00 -0700 Subject: [PATCH] Dashboard linting improvements for mixin Signed-off-by: Ryan J. Geyer --- .../dashboards/postgres-overview.json | 154 ++++++++---------- 1 file changed, 64 insertions(+), 90 deletions(-) diff --git a/postgres_mixin/dashboards/postgres-overview.json b/postgres_mixin/dashboards/postgres-overview.json index 5bea4926..9bf41be6 100644 --- a/postgres_mixin/dashboards/postgres-overview.json +++ b/postgres_mixin/dashboards/postgres-overview.json @@ -25,7 +25,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "Postgres Overview", + "datasource": "$datasource", "editable": true, "error": false, "fieldConfig": { @@ -77,7 +77,7 @@ { "alias": "fetched", "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_fetched{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(irate(pg_stat_database_tup_fetched{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -131,7 +131,7 @@ { "alias": "fetched", "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_returned{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(irate(pg_stat_database_tup_returned{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -185,7 +185,7 @@ { "alias": "fetched", "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_inserted{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(irate(pg_stat_database_tup_inserted{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -239,7 +239,7 @@ { "alias": "fetched", "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_updated{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(irate(pg_stat_database_tup_updated{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -293,7 +293,7 @@ { "alias": "fetched", "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_tup_deleted{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(irate(pg_stat_database_tup_deleted{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -396,7 +396,7 @@ "rgba(237, 129, 40, 0.89)", "rgba(50, 172, 45, 0.97)" ], - "datasource": "Postgres Overview", + "datasource": "$datasource", "decimals": 0, "editable": true, "error": false, @@ -460,7 +460,7 @@ "targets": [ { "dsType": "prometheus", - "expr": "sum(irate(pg_stat_database_xact_commit{datname=~\"$db\",instance=~\"$instance\"}[5m])) + sum(irate(pg_stat_database_xact_rollback{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(irate(pg_stat_database_xact_commit{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])) + sum(irate(pg_stat_database_xact_rollback{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -530,7 +530,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "Postgres Overview", + "datasource": "$datasource", "decimals": 1, "editable": true, "error": false, @@ -584,7 +584,7 @@ { "alias": "Buffers Allocated", "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_alloc_total{instance='$instance'}[5m])", + "expr": "irate(pg_stat_bgwriter_buffers_alloc{job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "groupBy": [ { @@ -636,7 +636,7 @@ { "alias": "Buffers Allocated", "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_backend_fsync_total{instance='$instance'}[5m])", + "expr": "irate(pg_stat_bgwriter_buffers_backend_fsync{job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "groupBy": [ { @@ -688,7 +688,7 @@ { "alias": "Buffers Allocated", "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_backend_total{instance='$instance'}[5m])", + "expr": "irate(pg_stat_bgwriter_buffers_backend{job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "groupBy": [ { @@ -740,7 +740,7 @@ { "alias": "Buffers Allocated", "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_clean_total{instance='$instance'}[5m])", + "expr": "irate(pg_stat_bgwriter_buffers_clean{job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "groupBy": [ { @@ -792,7 +792,7 @@ { "alias": "Buffers Allocated", "dsType": "prometheus", - "expr": "irate(pg_stat_bgwriter_buffers_checkpoint_total{instance='$instance'}[5m])", + "expr": "irate(pg_stat_bgwriter_buffers_checkpoint{job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])", "format": "time_series", "groupBy": [ { @@ -889,7 +889,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "Postgres Overview", + "datasource": "$datasource", "editable": true, "error": false, "fieldConfig": { @@ -939,7 +939,7 @@ { "alias": "conflicts", "dsType": "prometheus", - "expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -991,7 +991,7 @@ { "alias": "deadlocks", "dsType": "prometheus", - "expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",instance=~\"$instance\"}[5m]))", + "expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval]))", "format": "time_series", "groupBy": [ { @@ -1088,7 +1088,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "Postgres Overview", + "datasource": "$datasource", "editable": true, "error": false, "fieldConfig": { @@ -1136,10 +1136,10 @@ "steppedLine": false, "targets": [ { - "expr": "sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) / (sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$instance\"}) + sum(pg_stat_database_blks_read{datname=~\"$db\",instance=~\"$instance\"}))", + "expr": "sum by (datname) (rate(pg_stat_database_blks_hit{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])) / (sum by (datname)(rate(pg_stat_database_blks_hit{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])) + sum by (datname)(rate(pg_stat_database_blks_read{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}[$__rate_interval])))", "format": "time_series", "intervalFactor": 2, - "legendFormat": "cache hit rate", + "legendFormat": "{{datname}} - cache hit rate", "refId": "A", "step": 240 } @@ -1191,7 +1191,7 @@ "bars": false, "dashLength": 10, "dashes": false, - "datasource": "Postgres Overview", + "datasource": "$datasource", "editable": true, "error": false, "fieldConfig": { @@ -1239,10 +1239,10 @@ "steppedLine": false, "targets": [ { - "expr": "pg_stat_database_numbackends{datname=~\"$db\",instance=~\"$instance\"}", + "expr": "pg_stat_database_numbackends{datname=~\"$db\",job=~\"$job\",instance=~\"$instance\"}", "format": "time_series", "intervalFactor": 2, - "legendFormat": "{{__name__}}", + "legendFormat": "{{datname}} - {{__name__}}", "refId": "A", "step": 240 } @@ -1299,21 +1299,50 @@ "templating": { "list": [ { - "allValue": ".*", - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "Postgres Overview", + "hide": 0, + "includeAll": false, + "label": "Data Source", + "multi": false, + "name": "datasource", + "options": [], + "query": "prometheus", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + }, + { + "allValue": ".+", + "datasource": "$datasource", + "definition": "label_values(pg_up, job)", + "hide": 0, + "includeAll": true, + "label": "job", + "multi": true, + "name": "job", + "options": [], + "query": "label_values(pg_up, job)", + "refresh": 0, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + }, + { + "allValue": ".+", + "datasource": "$datasource", "definition": "", "hide": 0, "includeAll": true, - "label": null, - "multi": false, + "label": "instance", + "multi": true, "name": "instance", "options": [], - "query": "label_values(up{job=~\"postgres.*\"},instance)", + "query": "label_values(up{job=~\"$job\"},instance)", "refresh": 1, "regex": "", "skipUrlSync": false, @@ -1325,13 +1354,8 @@ "useTags": false }, { - "allValue": ".*", - "current": { - "selected": false, - "text": "All", - "value": "$__all" - }, - "datasource": "Postgres Overview", + "allValue": ".+", + "datasource": "$datasource", "definition": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)", "hide": 0, "includeAll": true, @@ -1349,56 +1373,6 @@ "tagsQuery": "", "type": "query", "useTags": false - }, - { - "current": { - "selected": false, - "text": "Postgres Overview", - "value": "Postgres Overview" - }, - "hide": 0, - "includeAll": false, - "label": "datasource", - "multi": false, - "name": "datasource", - "options": [], - "query": "prometheus", - "refresh": 1, - "regex": "", - "skipUrlSync": false, - "type": "datasource" - }, - { - "allValue": null, - "current": { - "selected": true, - "text": "postgres", - "value": "postgres" - }, - "datasource": "$datasource", - "definition": "label_values(pg_up, job)", - "hide": 0, - "includeAll": false, - "label": "job", - "multi": false, - "name": "job", - "options": [ - { - "selected": true, - "text": "postgres", - "value": "postgres" - } - ], - "query": "label_values(pg_up, job)", - "refresh": 0, - "regex": "", - "skipUrlSync": false, - "sort": 0, - "tagValuesQuery": "", - "tags": [], - "tagsQuery": "", - "type": "query", - "useTags": false } ] },