Add templating for job, instance and datasource

Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
This commit is contained in:
Kaviraj 2020-10-20 13:10:20 +02:00
parent 51225e1733
commit 2d6996bc31

View File

@ -1,40 +1,4 @@
{ {
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "5.2.0-pre1"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": "5.0.0"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "5.0.0"
},
{
"type": "panel",
"id": "singlestat",
"name": "Singlestat",
"version": "5.0.0"
}
],
"annotations": { "annotations": {
"list": [ "list": [
{ {
@ -52,8 +16,8 @@
"editable": true, "editable": true,
"gnetId": 455, "gnetId": 455,
"graphTooltip": 0, "graphTooltip": 0,
"id": null, "id": 1,
"iteration": 1534108418743, "iteration": 1603191461722,
"links": [], "links": [],
"panels": [ "panels": [
{ {
@ -61,10 +25,17 @@
"bars": false, "bars": false,
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "${DS_PROMETHEUS}", "datasource": "Postgres Overview",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -72,6 +43,7 @@
"x": 0, "x": 0,
"y": 0 "y": 0
}, },
"hiddenSeries": false,
"id": 1, "id": 1,
"isNew": true, "isNew": true,
"legend": { "legend": {
@ -89,7 +61,11 @@
"linewidth": 1, "linewidth": 1,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false, "percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
"renderer": "flot", "renderer": "flot",
@ -101,7 +77,7 @@
{ {
"alias": "fetched", "alias": "fetched",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(irate(pg_stat_database_tup_fetched{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(irate(pg_stat_database_tup_fetched{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -146,16 +122,16 @@
"step": 120, "step": 120,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "fetched", "alias": "fetched",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(irate(pg_stat_database_tup_returned{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(irate(pg_stat_database_tup_returned{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -200,16 +176,16 @@
"step": 120, "step": 120,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "fetched", "alias": "fetched",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(irate(pg_stat_database_tup_inserted{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(irate(pg_stat_database_tup_inserted{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -254,16 +230,16 @@
"step": 120, "step": 120,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "fetched", "alias": "fetched",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(irate(pg_stat_database_tup_updated{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(irate(pg_stat_database_tup_updated{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -308,16 +284,16 @@
"step": 120, "step": 120,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "fetched", "alias": "fetched",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(irate(pg_stat_database_tup_deleted{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(irate(pg_stat_database_tup_deleted{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -362,15 +338,16 @@
"step": 120, "step": 120,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
} }
], ],
"thresholds": [], "thresholds": [],
"timeFrom": null, "timeFrom": null,
"timeRegions": [],
"timeShift": null, "timeShift": null,
"title": "Rows", "title": "Rows",
"tooltip": { "tooltip": {
@ -404,7 +381,11 @@
"min": null, "min": null,
"show": true "show": true
} }
] ],
"yaxis": {
"align": false,
"alignLevel": null
}
}, },
{ {
"cacheTimeout": null, "cacheTimeout": null,
@ -415,10 +396,16 @@
"rgba(237, 129, 40, 0.89)", "rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)" "rgba(50, 172, 45, 0.97)"
], ],
"datasource": "${DS_PROMETHEUS}", "datasource": "Postgres Overview",
"decimals": 0, "decimals": 0,
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"format": "none", "format": "none",
"gauge": { "gauge": {
"maxValue": 100, "maxValue": 100,
@ -473,7 +460,7 @@
"targets": [ "targets": [
{ {
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(irate(pg_stat_database_xact_commit{datname=~\"$db\",instance=~\"$host\"}[5m])) + sum(irate(pg_stat_database_xact_rollback{datname=~\"$db\",instance=~\"$host\"}[5m]))", "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]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -517,9 +504,9 @@
"step": 1800, "step": 1800,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
} }
@ -543,11 +530,18 @@
"bars": false, "bars": false,
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "${DS_PROMETHEUS}", "datasource": "Postgres Overview",
"decimals": 1, "decimals": 1,
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -555,6 +549,7 @@
"x": 0, "x": 0,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 2, "id": 2,
"isNew": true, "isNew": true,
"legend": { "legend": {
@ -573,7 +568,11 @@
"linewidth": 1, "linewidth": 1,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false, "percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
"renderer": "flot", "renderer": "flot",
@ -585,7 +584,7 @@
{ {
"alias": "Buffers Allocated", "alias": "Buffers Allocated",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_alloc{instance='$host'}[5m])", "expr": "irate(pg_stat_bgwriter_buffers_alloc{instance='$instance'}[5m])",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -628,16 +627,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "Buffers Allocated", "alias": "Buffers Allocated",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_backend_fsync{instance='$host'}[5m])", "expr": "irate(pg_stat_bgwriter_buffers_backend_fsync{instance='$instance'}[5m])",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -680,16 +679,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "Buffers Allocated", "alias": "Buffers Allocated",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_backend{instance='$host'}[5m])", "expr": "irate(pg_stat_bgwriter_buffers_backend{instance='$instance'}[5m])",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -732,16 +731,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "Buffers Allocated", "alias": "Buffers Allocated",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_clean{instance='$host'}[5m])", "expr": "irate(pg_stat_bgwriter_buffers_clean{instance='$instance'}[5m])",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -784,16 +783,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "Buffers Allocated", "alias": "Buffers Allocated",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "irate(pg_stat_bgwriter_buffers_checkpoint{instance='$host'}[5m])", "expr": "irate(pg_stat_bgwriter_buffers_checkpoint{instance='$instance'}[5m])",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -836,15 +835,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
} }
], ],
"thresholds": [], "thresholds": [],
"timeFrom": null, "timeFrom": null,
"timeRegions": [],
"timeShift": null, "timeShift": null,
"title": "Buffers", "title": "Buffers",
"tooltip": { "tooltip": {
@ -878,17 +878,28 @@
"min": null, "min": null,
"show": true "show": true
} }
] ],
"yaxis": {
"align": false,
"alignLevel": null
}
}, },
{ {
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "${DS_PROMETHEUS}", "datasource": "Postgres Overview",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -896,6 +907,7 @@
"x": 12, "x": 12,
"y": 7 "y": 7
}, },
"hiddenSeries": false,
"id": 3, "id": 3,
"isNew": true, "isNew": true,
"legend": { "legend": {
@ -911,7 +923,11 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false, "percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
"renderer": "flot", "renderer": "flot",
@ -923,7 +939,7 @@
{ {
"alias": "conflicts", "alias": "conflicts",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(rate(pg_stat_database_deadlocks{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -966,16 +982,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
}, },
{ {
"alias": "deadlocks", "alias": "deadlocks",
"dsType": "prometheus", "dsType": "prometheus",
"expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",instance=~\"$host\"}[5m]))", "expr": "sum(rate(pg_stat_database_conflicts{datname=~\"$db\",instance=~\"$instance\"}[5m]))",
"format": "time_series", "format": "time_series",
"groupBy": [ "groupBy": [
{ {
@ -1018,15 +1034,16 @@
"step": 240, "step": 240,
"tags": [ "tags": [
{ {
"key": "host", "key": "instance",
"operator": "=~", "operator": "=~",
"value": "/^$host$/" "value": "/^$instance$/"
} }
] ]
} }
], ],
"thresholds": [], "thresholds": [],
"timeFrom": null, "timeFrom": null,
"timeRegions": [],
"timeShift": null, "timeShift": null,
"title": "Conflicts/Deadlocks", "title": "Conflicts/Deadlocks",
"tooltip": { "tooltip": {
@ -1060,17 +1077,28 @@
"min": null, "min": null,
"show": true "show": true
} }
] ],
"yaxis": {
"align": false,
"alignLevel": null
}
}, },
{ {
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "${DS_PROMETHEUS}", "datasource": "Postgres Overview",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -1078,6 +1106,7 @@
"x": 0, "x": 0,
"y": 14 "y": 14
}, },
"hiddenSeries": false,
"id": 12, "id": 12,
"isNew": true, "isNew": true,
"legend": { "legend": {
@ -1093,7 +1122,11 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": true, "percentage": true,
"pluginVersion": "7.2.1",
"pointradius": 1, "pointradius": 1,
"points": false, "points": false,
"renderer": "flot", "renderer": "flot",
@ -1103,7 +1136,7 @@
"steppedLine": false, "steppedLine": false,
"targets": [ "targets": [
{ {
"expr": "sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$host\"}) / (sum(pg_stat_database_blks_hit{datname=~\"$db\",instance=~\"$host\"}) + sum(pg_stat_database_blks_read{datname=~\"$db\",instance=~\"$host\"}))", "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\"}))",
"format": "time_series", "format": "time_series",
"intervalFactor": 2, "intervalFactor": 2,
"legendFormat": "cache hit rate", "legendFormat": "cache hit rate",
@ -1113,6 +1146,7 @@
], ],
"thresholds": [], "thresholds": [],
"timeFrom": null, "timeFrom": null,
"timeRegions": [],
"timeShift": null, "timeShift": null,
"title": "Cache hit ratio", "title": "Cache hit ratio",
"tooltip": { "tooltip": {
@ -1146,17 +1180,28 @@
"min": null, "min": null,
"show": true "show": true
} }
] ],
"yaxis": {
"align": false,
"alignLevel": null
}
}, },
{ {
"aliasColors": {}, "aliasColors": {},
"bars": false, "bars": false,
"dashLength": 10, "dashLength": 10,
"dashes": false, "dashes": false,
"datasource": "${DS_PROMETHEUS}", "datasource": "Postgres Overview",
"editable": true, "editable": true,
"error": false, "error": false,
"fieldConfig": {
"defaults": {
"custom": {}
},
"overrides": []
},
"fill": 1, "fill": 1,
"fillGradient": 0,
"grid": {}, "grid": {},
"gridPos": { "gridPos": {
"h": 7, "h": 7,
@ -1164,6 +1209,7 @@
"x": 12, "x": 12,
"y": 14 "y": 14
}, },
"hiddenSeries": false,
"id": 13, "id": 13,
"isNew": true, "isNew": true,
"legend": { "legend": {
@ -1179,7 +1225,11 @@
"linewidth": 2, "linewidth": 2,
"links": [], "links": [],
"nullPointMode": "connected", "nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false, "percentage": false,
"pluginVersion": "7.2.1",
"pointradius": 5, "pointradius": 5,
"points": false, "points": false,
"renderer": "flot", "renderer": "flot",
@ -1189,7 +1239,7 @@
"steppedLine": false, "steppedLine": false,
"targets": [ "targets": [
{ {
"expr": "pg_stat_database_numbackends{datname=~\"$db\",instance=~\"$host\"}", "expr": "pg_stat_database_numbackends{datname=~\"$db\",instance=~\"$instance\"}",
"format": "time_series", "format": "time_series",
"intervalFactor": 2, "intervalFactor": 2,
"legendFormat": "{{__name__}}", "legendFormat": "{{__name__}}",
@ -1199,6 +1249,7 @@
], ],
"thresholds": [], "thresholds": [],
"timeFrom": null, "timeFrom": null,
"timeRegions": [],
"timeShift": null, "timeShift": null,
"title": "Number of active connections", "title": "Number of active connections",
"tooltip": { "tooltip": {
@ -1232,11 +1283,15 @@
"min": null, "min": null,
"show": true "show": true
} }
] ],
"yaxis": {
"align": false,
"alignLevel": null
}
} }
], ],
"refresh": false, "refresh": false,
"schemaVersion": 16, "schemaVersion": 26,
"style": "dark", "style": "dark",
"tags": [ "tags": [
"postgres" "postgres"
@ -1245,17 +1300,23 @@
"list": [ "list": [
{ {
"allValue": ".*", "allValue": ".*",
"current": {}, "current": {
"datasource": "${DS_PROMETHEUS}", "selected": false,
"text": "All",
"value": "$__all"
},
"datasource": "Postgres Overview",
"definition": "",
"hide": 0, "hide": 0,
"includeAll": true, "includeAll": true,
"label": null, "label": null,
"multi": false, "multi": false,
"name": "host", "name": "instance",
"options": [], "options": [],
"query": "label_values(up{job=~\"postgres.*\"},instance)", "query": "label_values(up{job=~\"postgres.*\"},instance)",
"refresh": 1, "refresh": 1,
"regex": "", "regex": "",
"skipUrlSync": false,
"sort": 0, "sort": 0,
"tagValuesQuery": "", "tagValuesQuery": "",
"tags": [], "tags": [],
@ -1265,17 +1326,73 @@
}, },
{ {
"allValue": ".*", "allValue": ".*",
"current": {}, "current": {
"datasource": "${DS_PROMETHEUS}", "selected": false,
"text": "All",
"value": "$__all"
},
"datasource": "Postgres Overview",
"definition": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)",
"hide": 0, "hide": 0,
"includeAll": true, "includeAll": true,
"label": "db", "label": "db",
"multi": false, "multi": false,
"name": "db", "name": "db",
"options": [], "options": [],
"query": "label_values(pg_stat_database_tup_fetched{instance=~\"$host\",datname!~\"template.*|postgres\"},datname)", "query": "label_values(pg_stat_database_tup_fetched{instance=~\"$instance\",datname!~\"template.*|postgres\"},datname)",
"refresh": 1, "refresh": 1,
"regex": "", "regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"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, "sort": 0,
"tagValuesQuery": "", "tagValuesQuery": "",
"tags": [], "tags": [],
@ -1317,5 +1434,5 @@
"timezone": "browser", "timezone": "browser",
"title": "Postgres Overview", "title": "Postgres Overview",
"uid": "wGgaPlciz", "uid": "wGgaPlciz",
"version": 4 "version": 5
} }