From ae08a798b60fba16e4e0eb87260339fe38adc99e Mon Sep 17 00:00:00 2001 From: Hector Date: Thu, 23 Dec 2021 11:39:15 +0000 Subject: [PATCH] refactor: update grafana dashboard (#15) Update the sample Grafana dashboard to use a variable for the data source. All panels have been updated to use the new variable. This makes it easier to import the dashboard and have it work with different data sources. --- README.md | 2 +- grafana.json | 147 +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 119 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 2a534fc..fb56af8 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The default location of the socket is: `/var/run/fail2ban/fail2ban.sock` The metrics exported by this tool are compatible with Prometheus and Grafana. A sample grafana dashboard can be found in the `grafana.json` file. Just import the contents of this file into a new Grafana dashboard to get started. -*(Sample dashboard is compatible with Grafana `8.2.1` and above)* +*(Sample dashboard is compatible with Grafana `8.3.3` and above)* ## 2. Running the Exporter diff --git a/grafana.json b/grafana.json index feb29d1..8d6b375 100644 --- a/grafana.json +++ b/grafana.json @@ -1,11 +1,27 @@ { - "__inputs": [], + "__inputs": [ + { + "name": "DS_PROMETHEUS", + "label": "Prometheus", + "description": "", + "type": "datasource", + "pluginId": "prometheus", + "pluginName": "Prometheus" + } + ], + "__elements": [], "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", - "version": "8.2.1" + "version": "8.3.3" + }, + { + "type": "datasource", + "id": "prometheus", + "name": "Prometheus", + "version": "1.0.0" }, { "type": "panel", @@ -41,14 +57,17 @@ }, "editable": true, "fiscalYearStartMonth": 0, - "gnetId": null, "graphTooltip": 2, "id": null, + "iteration": 1640159475017, "links": [], "liveNow": false, "panels": [ { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -93,12 +112,23 @@ }, "id": 206, "options": { + "footer": { + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, "showHeader": true }, - "pluginVersion": "8.2.1", + "pluginVersion": "8.3.3", "targets": [ { - "exemplar": true, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": false, "expr": "f2b_config_jail_max_retries", "format": "table", "instant": true, @@ -107,7 +137,11 @@ "refId": "A" }, { - "exemplar": true, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": false, "expr": "f2b_config_jail_ban_time", "format": "table", "hide": false, @@ -117,7 +151,11 @@ "refId": "B" }, { - "exemplar": true, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, + "exemplar": false, "expr": "f2b_config_jail_find_time", "format": "table", "hide": false, @@ -180,7 +218,10 @@ "type": "table" }, { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -252,6 +293,10 @@ "pluginVersion": "8.2.1", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "exemplar": true, "expr": "f2b_jail_failed_total", "hide": false, @@ -260,14 +305,15 @@ "refId": "A" } ], - "timeFrom": null, - "timeShift": null, "title": "Fail2Ban Failures (Total)", "transparent": true, "type": "timeseries" }, { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -339,6 +385,10 @@ "pluginVersion": "8.2.1", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "exemplar": true, "expr": "f2b_jail_banned_total", "interval": "", @@ -346,14 +396,15 @@ "refId": "A" } ], - "timeFrom": null, - "timeShift": null, "title": "Fail2Ban Bans (Total)", "transparent": true, "type": "timeseries" }, { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -425,6 +476,10 @@ "pluginVersion": "8.2.1", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "exemplar": true, "expr": "f2b_jail_failed_current", "interval": "", @@ -432,14 +487,15 @@ "refId": "A" } ], - "timeFrom": null, - "timeShift": null, "title": "Fail2Ban Failures (Current)", "transparent": true, "type": "timeseries" }, { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -511,6 +567,10 @@ "pluginVersion": "8.2.1", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "exemplar": true, "expr": "f2b_jail_banned_current", "interval": "", @@ -518,14 +578,15 @@ "refId": "A" } ], - "timeFrom": null, - "timeShift": null, "title": "Fail2Ban Bans (Current)", "transparent": true, "type": "timeseries" }, { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -598,6 +659,10 @@ "pluginVersion": "8.2.1", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "exemplar": true, "expr": "f2b_up", "interval": "", @@ -605,14 +670,15 @@ "refId": "A" } ], - "timeFrom": null, - "timeShift": null, "title": "Fail2Ban Up", "transparent": true, "type": "timeseries" }, { - "datasource": null, + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "description": "", "fieldConfig": { "defaults": { @@ -685,6 +751,10 @@ "pluginVersion": "8.2.1", "targets": [ { + "datasource": { + "type": "prometheus", + "uid": "${DS_PROMETHEUS}" + }, "exemplar": true, "expr": "f2b_errors", "interval": "", @@ -692,19 +762,37 @@ "refId": "A" } ], - "timeFrom": null, - "timeShift": null, "title": "Fail2Ban Exporter Errors", "transparent": true, "type": "timeseries" } ], "refresh": "30s", - "schemaVersion": 31, + "schemaVersion": 34, "style": "dark", "tags": [], "templating": { - "list": [] + "list": [ + { + "current": { + "selected": true, + "text": "Prometheus", + "value": "Prometheus" + }, + "hide": 0, + "includeAll": false, + "label": "Data Source", + "multi": false, + "name": "DataSource", + "options": [], + "query": "prometheus", + "queryValue": "", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "type": "datasource" + } + ] }, "time": { "from": "now-6h", @@ -714,5 +802,6 @@ "timezone": "", "title": "F2B", "uid": "cTkH9AT7z", - "version": 13 + "version": 17, + "weekStart": "" }