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.
This commit is contained in:
Hector 2021-12-23 11:39:15 +00:00
parent cf71dc7449
commit ae08a798b6
2 changed files with 119 additions and 30 deletions

View file

@ -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. 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 ## 2. Running the Exporter

View file

@ -1,11 +1,27 @@
{ {
"__inputs": [], "__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__elements": [],
"__requires": [ "__requires": [
{ {
"type": "grafana", "type": "grafana",
"id": "grafana", "id": "grafana",
"name": "Grafana", "name": "Grafana",
"version": "8.2.1" "version": "8.3.3"
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
}, },
{ {
"type": "panel", "type": "panel",
@ -41,14 +57,17 @@
}, },
"editable": true, "editable": true,
"fiscalYearStartMonth": 0, "fiscalYearStartMonth": 0,
"gnetId": null,
"graphTooltip": 2, "graphTooltip": 2,
"id": null, "id": null,
"iteration": 1640159475017,
"links": [], "links": [],
"liveNow": false, "liveNow": false,
"panels": [ "panels": [
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -93,12 +112,23 @@
}, },
"id": 206, "id": 206,
"options": { "options": {
"footer": {
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true "showHeader": true
}, },
"pluginVersion": "8.2.1", "pluginVersion": "8.3.3",
"targets": [ "targets": [
{ {
"exemplar": true, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": false,
"expr": "f2b_config_jail_max_retries", "expr": "f2b_config_jail_max_retries",
"format": "table", "format": "table",
"instant": true, "instant": true,
@ -107,7 +137,11 @@
"refId": "A" "refId": "A"
}, },
{ {
"exemplar": true, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": false,
"expr": "f2b_config_jail_ban_time", "expr": "f2b_config_jail_ban_time",
"format": "table", "format": "table",
"hide": false, "hide": false,
@ -117,7 +151,11 @@
"refId": "B" "refId": "B"
}, },
{ {
"exemplar": true, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": false,
"expr": "f2b_config_jail_find_time", "expr": "f2b_config_jail_find_time",
"format": "table", "format": "table",
"hide": false, "hide": false,
@ -180,7 +218,10 @@
"type": "table" "type": "table"
}, },
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -252,6 +293,10 @@
"pluginVersion": "8.2.1", "pluginVersion": "8.2.1",
"targets": [ "targets": [
{ {
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": true, "exemplar": true,
"expr": "f2b_jail_failed_total", "expr": "f2b_jail_failed_total",
"hide": false, "hide": false,
@ -260,14 +305,15 @@
"refId": "A" "refId": "A"
} }
], ],
"timeFrom": null,
"timeShift": null,
"title": "Fail2Ban Failures (Total)", "title": "Fail2Ban Failures (Total)",
"transparent": true, "transparent": true,
"type": "timeseries" "type": "timeseries"
}, },
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -339,6 +385,10 @@
"pluginVersion": "8.2.1", "pluginVersion": "8.2.1",
"targets": [ "targets": [
{ {
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": true, "exemplar": true,
"expr": "f2b_jail_banned_total", "expr": "f2b_jail_banned_total",
"interval": "", "interval": "",
@ -346,14 +396,15 @@
"refId": "A" "refId": "A"
} }
], ],
"timeFrom": null,
"timeShift": null,
"title": "Fail2Ban Bans (Total)", "title": "Fail2Ban Bans (Total)",
"transparent": true, "transparent": true,
"type": "timeseries" "type": "timeseries"
}, },
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -425,6 +476,10 @@
"pluginVersion": "8.2.1", "pluginVersion": "8.2.1",
"targets": [ "targets": [
{ {
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": true, "exemplar": true,
"expr": "f2b_jail_failed_current", "expr": "f2b_jail_failed_current",
"interval": "", "interval": "",
@ -432,14 +487,15 @@
"refId": "A" "refId": "A"
} }
], ],
"timeFrom": null,
"timeShift": null,
"title": "Fail2Ban Failures (Current)", "title": "Fail2Ban Failures (Current)",
"transparent": true, "transparent": true,
"type": "timeseries" "type": "timeseries"
}, },
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -511,6 +567,10 @@
"pluginVersion": "8.2.1", "pluginVersion": "8.2.1",
"targets": [ "targets": [
{ {
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": true, "exemplar": true,
"expr": "f2b_jail_banned_current", "expr": "f2b_jail_banned_current",
"interval": "", "interval": "",
@ -518,14 +578,15 @@
"refId": "A" "refId": "A"
} }
], ],
"timeFrom": null,
"timeShift": null,
"title": "Fail2Ban Bans (Current)", "title": "Fail2Ban Bans (Current)",
"transparent": true, "transparent": true,
"type": "timeseries" "type": "timeseries"
}, },
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -598,6 +659,10 @@
"pluginVersion": "8.2.1", "pluginVersion": "8.2.1",
"targets": [ "targets": [
{ {
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": true, "exemplar": true,
"expr": "f2b_up", "expr": "f2b_up",
"interval": "", "interval": "",
@ -605,14 +670,15 @@
"refId": "A" "refId": "A"
} }
], ],
"timeFrom": null,
"timeShift": null,
"title": "Fail2Ban Up", "title": "Fail2Ban Up",
"transparent": true, "transparent": true,
"type": "timeseries" "type": "timeseries"
}, },
{ {
"datasource": null, "datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"description": "", "description": "",
"fieldConfig": { "fieldConfig": {
"defaults": { "defaults": {
@ -685,6 +751,10 @@
"pluginVersion": "8.2.1", "pluginVersion": "8.2.1",
"targets": [ "targets": [
{ {
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"exemplar": true, "exemplar": true,
"expr": "f2b_errors", "expr": "f2b_errors",
"interval": "", "interval": "",
@ -692,19 +762,37 @@
"refId": "A" "refId": "A"
} }
], ],
"timeFrom": null,
"timeShift": null,
"title": "Fail2Ban Exporter Errors", "title": "Fail2Ban Exporter Errors",
"transparent": true, "transparent": true,
"type": "timeseries" "type": "timeseries"
} }
], ],
"refresh": "30s", "refresh": "30s",
"schemaVersion": 31, "schemaVersion": 34,
"style": "dark", "style": "dark",
"tags": [], "tags": [],
"templating": { "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": { "time": {
"from": "now-6h", "from": "now-6h",
@ -714,5 +802,6 @@
"timezone": "", "timezone": "",
"title": "F2B", "title": "F2B",
"uid": "cTkH9AT7z", "uid": "cTkH9AT7z",
"version": 13 "version": 17,
"weekStart": ""
} }