summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inventory/host_vars/ch-mon.yml6
-rw-r--r--roles/monitoring/grafana/defaults/main.yml3
-rw-r--r--roles/monitoring/grafana/files/dashboard-blackbox/https.json (renamed from roles/monitoring/grafana/files/dashboard-blackbox.json)94
-rw-r--r--roles/monitoring/grafana/files/dashboard-blackbox/mqtt.json823
-rw-r--r--roles/monitoring/grafana/files/dashboard-blackbox/ssh.json725
-rw-r--r--roles/monitoring/grafana/filter_plugins/grafana.py31
-rw-r--r--roles/monitoring/grafana/tasks/main.yml24
7 files changed, 1659 insertions, 47 deletions
diff --git a/inventory/host_vars/ch-mon.yml b/inventory/host_vars/ch-mon.yml
index 4f5371ab..0b830a88 100644
--- a/inventory/host_vars/ch-mon.yml
+++ b/inventory/host_vars/ch-mon.yml
@@ -268,7 +268,11 @@ grafana_dashboards:
datasource: "Prometheus"
- file: environment-sensors
datasource: "Prometheus"
- - file: blackbox
+ - file: blackbox/ssh
+ datasource: "Prometheus"
+ - file: blackbox/https
+ datasource: "Prometheus"
+ - file: blackbox/mqtt
datasource: "Prometheus"
- file: smokeping
datasource: "Prometheus"
diff --git a/roles/monitoring/grafana/defaults/main.yml b/roles/monitoring/grafana/defaults/main.yml
index 20b886ca..39ea145a 100644
--- a/roles/monitoring/grafana/defaults/main.yml
+++ b/roles/monitoring/grafana/defaults/main.yml
@@ -55,9 +55,6 @@ grafana_dashboards: []
# - content: '... json-data ...'
# name: bar
# datasource: "Graphite"
-# - id: 19
-# revision: 3
-# datasource: "Foo"
grafana_admin_password: "{{ undef(hint='Please specify the password for the grafana admin user') }}"
diff --git a/roles/monitoring/grafana/files/dashboard-blackbox.json b/roles/monitoring/grafana/files/dashboard-blackbox/https.json
index 448d605c..0d322f3d 100644
--- a/roles/monitoring/grafana/files/dashboard-blackbox.json
+++ b/roles/monitoring/grafana/files/dashboard-blackbox/https.json
@@ -15,7 +15,7 @@
"type": "grafana",
"id": "grafana",
"name": "Grafana",
- "version": "10.4.0"
+ "version": "11.0.0"
},
{
"type": "datasource",
@@ -58,7 +58,7 @@
}
]
},
- "description": "Blackbox Exporter Overview",
+ "description": "Blackbox Exporter http/https Targets",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 7587,
@@ -83,6 +83,7 @@
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
+ "axisSoftMin": 0,
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
@@ -142,6 +143,7 @@
"showLegend": true
},
"tooltip": {
+ "maxHeight": 600,
"mode": "multi",
"sort": "asc"
}
@@ -153,11 +155,13 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_duration_seconds{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_duration_seconds{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
- "legendFormat": "{{ instance }}",
+ "legendFormat": "{{ svc_name }}",
+ "range": true,
"refId": "A"
}
],
@@ -179,6 +183,7 @@
"id": 15,
"panels": [],
"repeat": "target",
+ "repeatDirection": "h",
"targets": [
{
"datasource": {
@@ -188,7 +193,7 @@
"refId": "A"
}
],
- "title": "$target status",
+ "title": "$target",
"type": "row"
},
{
@@ -268,7 +273,7 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"repeatDirection": "v",
"targets": [
{
@@ -276,10 +281,12 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_success{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_success{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -361,6 +368,7 @@
"showLegend": true
},
"tooltip": {
+ "maxHeight": 600,
"mode": "multi",
"sort": "none"
}
@@ -372,11 +380,13 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_http_duration_seconds{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_http_duration_seconds{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
"legendFormat": "{{ phase }}",
+ "range": true,
"refId": "B"
}
],
@@ -391,7 +401,7 @@
"fieldConfig": {
"defaults": {
"color": {
- "mode": "palette-classic"
+ "mode": "thresholds"
},
"custom": {
"axisBorderShow": false,
@@ -399,10 +409,11 @@
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
+ "axisSoftMin": 0,
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
- "gradientMode": "none",
+ "gradientMode": "scheme",
"hideFrom": {
"legend": false,
"tooltip": false,
@@ -434,8 +445,12 @@
"value": null
},
{
+ "color": "orange",
+ "value": 0.2
+ },
+ {
"color": "red",
- "value": 80
+ "value": 1
}
]
},
@@ -455,9 +470,10 @@
"calcs": [],
"displayMode": "list",
"placement": "bottom",
- "showLegend": true
+ "showLegend": false
},
"tooltip": {
+ "maxHeight": 600,
"mode": "multi",
"sort": "none"
}
@@ -469,11 +485,13 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_duration_seconds{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_duration_seconds{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
"legendFormat": "seconds",
+ "range": true,
"refId": "A"
}
],
@@ -558,7 +576,7 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"repeatDirection": "h",
"targets": [
{
@@ -566,10 +584,12 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_http_status_code{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_http_status_code{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -638,16 +658,18 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_http_version{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_http_version{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -731,7 +753,7 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"repeatDirection": "v",
"targets": [
{
@@ -739,10 +761,12 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_http_ssl{instance=~\"$target\"}",
+ "editorMode": "code",
+ "expr": "probe_http_ssl{svc_kind=~\"https?\", svc_name=~\"$target\"}",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -827,7 +851,7 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"repeatDirection": "h",
"targets": [
{
@@ -835,10 +859,12 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "probe_ssl_earliest_cert_expiry{instance=~\"$target\"} - time()",
+ "editorMode": "code",
+ "expr": "probe_ssl_earliest_cert_expiry{svc_kind=~\"https?\", svc_name=~\"$target\"} - time()",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -907,17 +933,19 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "avg(probe_duration_seconds{instance=~\"$target\"})",
+ "editorMode": "code",
+ "expr": "avg(probe_duration_seconds{svc_kind=~\"https?\", svc_name=~\"$target\"})",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -986,7 +1014,7 @@
"textMode": "auto",
"wideLayout": true
},
- "pluginVersion": "10.4.0",
+ "pluginVersion": "11.0.0",
"repeatDirection": "h",
"targets": [
{
@@ -994,10 +1022,12 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "expr": "avg(probe_dns_lookup_time_seconds{instance=~\"$target\"})",
+ "editorMode": "code",
+ "expr": "avg(probe_dns_lookup_time_seconds{svc_kind=~\"https?\", svc_name=~\"$target\"})",
"format": "time_series",
"interval": "$interval",
"intervalFactor": 1,
+ "range": true,
"refId": "A"
}
],
@@ -1109,15 +1139,16 @@
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
- "definition": "",
+ "definition": "label_values(probe_success{svc_kind=~\"https?\"},svc_name)",
"hide": 0,
"includeAll": true,
"multi": true,
"name": "target",
"options": [],
"query": {
- "query": "label_values(probe_success, instance)",
- "refId": "Prometheus-target-Variable-Query"
+ "qryType": 1,
+ "query": "label_values(probe_success{svc_kind=~\"https?\"},svc_name)",
+ "refId": "PrometheusVariableQueryEditor-VariableQuery"
},
"refresh": 1,
"regex": "",
@@ -1134,6 +1165,7 @@
"from": "now-6h",
"to": "now"
},
+ "timeRangeUpdatedDuringEditOrView": false,
"timepicker": {
"refresh_intervals": [
"5s",
@@ -1160,8 +1192,8 @@
]
},
"timezone": "",
- "title": "Blackbox Exporter",
- "uid": "xtkCtBkiz",
- "version": 1,
+ "title": "http/https",
+ "uid": "edp9yl8cgfd34b",
+ "version": 8,
"weekStart": ""
} \ No newline at end of file
diff --git a/roles/monitoring/grafana/files/dashboard-blackbox/mqtt.json b/roles/monitoring/grafana/files/dashboard-blackbox/mqtt.json
new file mode 100644
index 00000000..40eddf82
--- /dev/null
+++ b/roles/monitoring/grafana/files/dashboard-blackbox/mqtt.json
@@ -0,0 +1,823 @@
+{
+ "__inputs": [
+ {
+ "name": "DS_PROMETHEUS",
+ "label": "Prometheus",
+ "description": "",
+ "type": "datasource",
+ "pluginId": "prometheus",
+ "pluginName": "Prometheus"
+ }
+ ],
+ "__elements": {},
+ "__requires": [
+ {
+ "type": "grafana",
+ "id": "grafana",
+ "name": "Grafana",
+ "version": "11.0.0"
+ },
+ {
+ "type": "datasource",
+ "id": "prometheus",
+ "name": "Prometheus",
+ "version": "1.0.0"
+ },
+ {
+ "type": "panel",
+ "id": "stat",
+ "name": "Stat",
+ "version": ""
+ },
+ {
+ "type": "panel",
+ "id": "timeseries",
+ "name": "Time series",
+ "version": ""
+ }
+ ],
+ "annotations": {
+ "list": [
+ {
+ "builtIn": 1,
+ "datasource": {
+ "type": "datasource",
+ "uid": "grafana"
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "target": {
+ "limit": 100,
+ "matchAny": false,
+ "tags": [],
+ "type": "dashboard"
+ },
+ "type": "dashboard"
+ }
+ ]
+ },
+ "description": "Blackbox Exporter MQTT Targets",
+ "editable": true,
+ "fiscalYearStartMonth": 0,
+ "gnetId": 7587,
+ "graphTooltip": 0,
+ "id": null,
+ "links": [],
+ "liveNow": false,
+ "panels": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "axisSoftMin": 0,
+ "barAlignment": 0,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ },
+ "mappings": [],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "red",
+ "value": 80
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 8,
+ "w": 24,
+ "x": 0,
+ "y": 0
+ },
+ "id": 138,
+ "options": {
+ "legend": {
+ "calcs": [],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "maxHeight": 600,
+ "mode": "multi",
+ "sort": "asc"
+ }
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_duration_seconds{svc_kind=~\"mqtt\", svc_name=~\"$target\"}",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "legendFormat": "{{ svc_name }}",
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Global Probe Duration",
+ "type": "timeseries"
+ },
+ {
+ "collapsed": false,
+ "datasource": {
+ "type": "prometheus",
+ "uid": "PBFA97CFB590B2093"
+ },
+ "gridPos": {
+ "h": 1,
+ "w": 24,
+ "x": 0,
+ "y": 8
+ },
+ "id": 15,
+ "panels": [],
+ "repeat": "target",
+ "repeatDirection": "h",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "PBFA97CFB590B2093"
+ },
+ "refId": "A"
+ }
+ ],
+ "title": "$target",
+ "type": "row"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "mappings": [
+ {
+ "options": {
+ "0": {
+ "text": "DOWN"
+ },
+ "1": {
+ "text": "UP"
+ }
+ },
+ "type": "value"
+ },
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "#d44a3a",
+ "value": null
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 1
+ },
+ {
+ "color": "#299c46",
+ "value": 1
+ }
+ ]
+ },
+ "unit": "none"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 8,
+ "x": 0,
+ "y": 9
+ },
+ "id": 2,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "background",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "repeatDirection": "v",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_success{svc_kind=\"mqtt\", svc_name=~\"$target\"}",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Status",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "mappings": [
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "red",
+ "value": 80
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 5,
+ "x": 8,
+ "y": 9
+ },
+ "id": 23,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "avg(probe_duration_seconds{svc_kind=\"mqtt\", svc_name=~\"$target\"})",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Average Probe Duration",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "axisSoftMin": 0,
+ "barAlignment": 0,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "scheme",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ },
+ "mappings": [],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "orange",
+ "value": 0.2
+ },
+ {
+ "color": "red",
+ "value": 1
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 6,
+ "w": 11,
+ "x": 13,
+ "y": 9
+ },
+ "id": 17,
+ "options": {
+ "legend": {
+ "calcs": [],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": false
+ },
+ "tooltip": {
+ "maxHeight": 600,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_duration_seconds{svc_kind=\"mqtt\", svc_name=~\"$target\"}",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "legendFormat": "seconds",
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "type": "timeseries"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "decimals": 2,
+ "mappings": [
+ {
+ "options": {
+ "0": {
+ "text": "NO"
+ },
+ "1": {
+ "text": "YES"
+ }
+ },
+ "type": "value"
+ },
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "#d44a3a",
+ "value": null
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 0
+ },
+ {
+ "color": "#299c46",
+ "value": 1209600
+ }
+ ]
+ },
+ "unit": "dtdurations"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 8,
+ "x": 0,
+ "y": 12
+ },
+ "id": 19,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "value",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "repeatDirection": "h",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_ssl_earliest_cert_expiry{svc_kind=\"mqtt\", svc_name=~\"$target\"} - time()",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "SSL Expiry",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "mappings": [
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "red",
+ "value": 80
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 5,
+ "x": 8,
+ "y": 12
+ },
+ "id": 24,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "repeatDirection": "h",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "avg(probe_dns_lookup_time_seconds{svc_kind=\"mqtt\", svc_name=~\"$target\"})",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Average DNS Lookup",
+ "type": "stat"
+ }
+ ],
+ "refresh": "10s",
+ "schemaVersion": 39,
+ "tags": [
+ "blackbox",
+ "prometheus"
+ ],
+ "templating": {
+ "list": [
+ {
+ "auto": true,
+ "auto_count": 10,
+ "auto_min": "10s",
+ "current": {
+ "selected": false,
+ "text": "10s",
+ "value": "10s"
+ },
+ "hide": 0,
+ "label": "Interval",
+ "name": "interval",
+ "options": [
+ {
+ "selected": false,
+ "text": "auto",
+ "value": "$__auto_interval_interval"
+ },
+ {
+ "selected": false,
+ "text": "5s",
+ "value": "5s"
+ },
+ {
+ "selected": true,
+ "text": "10s",
+ "value": "10s"
+ },
+ {
+ "selected": false,
+ "text": "30s",
+ "value": "30s"
+ },
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ },
+ {
+ "selected": false,
+ "text": "7d",
+ "value": "7d"
+ },
+ {
+ "selected": false,
+ "text": "14d",
+ "value": "14d"
+ },
+ {
+ "selected": false,
+ "text": "30d",
+ "value": "30d"
+ }
+ ],
+ "query": "5s,10s,30s,1m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
+ "queryValue": "",
+ "refresh": 2,
+ "skipUrlSync": false,
+ "type": "interval"
+ },
+ {
+ "current": {},
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "definition": "label_values(probe_success{svc_kind=~\"mqtt\"},svc_name)",
+ "hide": 0,
+ "includeAll": true,
+ "multi": true,
+ "name": "target",
+ "options": [],
+ "query": {
+ "qryType": 1,
+ "query": "label_values(probe_success{svc_kind=~\"mqtt\"},svc_name)",
+ "refId": "PrometheusVariableQueryEditor-VariableQuery"
+ },
+ "refresh": 1,
+ "regex": "",
+ "skipUrlSync": false,
+ "sort": 0,
+ "tagValuesQuery": "",
+ "tagsQuery": "",
+ "type": "query",
+ "useTags": false
+ }
+ ]
+ },
+ "time": {
+ "from": "now-6h",
+ "to": "now"
+ },
+ "timeRangeUpdatedDuringEditOrView": false,
+ "timepicker": {
+ "refresh_intervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "time_options": [
+ "5m",
+ "15m",
+ "1h",
+ "6h",
+ "12h",
+ "24h",
+ "2d",
+ "7d",
+ "30d"
+ ]
+ },
+ "timezone": "",
+ "title": "mqtt",
+ "uid": "ddpa033pbeubkb",
+ "version": 4,
+ "weekStart": ""
+} \ No newline at end of file
diff --git a/roles/monitoring/grafana/files/dashboard-blackbox/ssh.json b/roles/monitoring/grafana/files/dashboard-blackbox/ssh.json
new file mode 100644
index 00000000..93c3206f
--- /dev/null
+++ b/roles/monitoring/grafana/files/dashboard-blackbox/ssh.json
@@ -0,0 +1,725 @@
+{
+ "__inputs": [
+ {
+ "name": "DS_PROMETHEUS",
+ "label": "Prometheus",
+ "description": "",
+ "type": "datasource",
+ "pluginId": "prometheus",
+ "pluginName": "Prometheus"
+ }
+ ],
+ "__elements": {},
+ "__requires": [
+ {
+ "type": "grafana",
+ "id": "grafana",
+ "name": "Grafana",
+ "version": "11.0.0"
+ },
+ {
+ "type": "datasource",
+ "id": "prometheus",
+ "name": "Prometheus",
+ "version": "1.0.0"
+ },
+ {
+ "type": "panel",
+ "id": "stat",
+ "name": "Stat",
+ "version": ""
+ },
+ {
+ "type": "panel",
+ "id": "timeseries",
+ "name": "Time series",
+ "version": ""
+ }
+ ],
+ "annotations": {
+ "list": [
+ {
+ "builtIn": 1,
+ "datasource": {
+ "type": "datasource",
+ "uid": "grafana"
+ },
+ "enable": true,
+ "hide": true,
+ "iconColor": "rgba(0, 211, 255, 1)",
+ "name": "Annotations & Alerts",
+ "target": {
+ "limit": 100,
+ "matchAny": false,
+ "tags": [],
+ "type": "dashboard"
+ },
+ "type": "dashboard"
+ }
+ ]
+ },
+ "description": "Blackbox Exporter SSH Targets",
+ "editable": true,
+ "fiscalYearStartMonth": 0,
+ "gnetId": 7587,
+ "graphTooltip": 0,
+ "id": null,
+ "links": [],
+ "liveNow": false,
+ "panels": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "palette-classic"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "axisSoftMin": 0,
+ "barAlignment": 0,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "none",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ },
+ "mappings": [],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "red",
+ "value": 80
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 8,
+ "w": 24,
+ "x": 0,
+ "y": 0
+ },
+ "id": 138,
+ "options": {
+ "legend": {
+ "calcs": [],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": true
+ },
+ "tooltip": {
+ "maxHeight": 600,
+ "mode": "multi",
+ "sort": "asc"
+ }
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_duration_seconds{svc_kind=\"ssh\", svc_name=~\"$target\"}",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "legendFormat": "{{ svc_name }}",
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Global Probe Duration",
+ "type": "timeseries"
+ },
+ {
+ "collapsed": false,
+ "datasource": {
+ "type": "prometheus",
+ "uid": "PBFA97CFB590B2093"
+ },
+ "gridPos": {
+ "h": 1,
+ "w": 24,
+ "x": 0,
+ "y": 8
+ },
+ "id": 15,
+ "panels": [],
+ "repeat": "target",
+ "repeatDirection": "h",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "PBFA97CFB590B2093"
+ },
+ "refId": "A"
+ }
+ ],
+ "title": "$target",
+ "type": "row"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "mappings": [
+ {
+ "options": {
+ "0": {
+ "text": "DOWN"
+ },
+ "1": {
+ "text": "UP"
+ }
+ },
+ "type": "value"
+ },
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "#d44a3a",
+ "value": null
+ },
+ {
+ "color": "rgba(237, 129, 40, 0.89)",
+ "value": 1
+ },
+ {
+ "color": "#299c46",
+ "value": 1
+ }
+ ]
+ },
+ "unit": "none"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 4,
+ "x": 0,
+ "y": 9
+ },
+ "id": 2,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "background",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "repeatDirection": "v",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_success{svc_kind=\"ssh\", svc_name=\"$target\"}",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Status",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "mappings": [
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "red",
+ "value": 80
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 4,
+ "x": 4,
+ "y": 9
+ },
+ "id": 23,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "avg(probe_duration_seconds{svc_kind=\"ssh\", svc_name=\"$target\"})",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Average Probe Duration",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "mappings": [
+ {
+ "options": {
+ "match": "null",
+ "result": {
+ "text": "N/A"
+ }
+ },
+ "type": "special"
+ }
+ ],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "red",
+ "value": 80
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 4,
+ "x": 8,
+ "y": 9
+ },
+ "id": 24,
+ "maxDataPoints": 100,
+ "options": {
+ "colorMode": "none",
+ "graphMode": "none",
+ "justifyMode": "auto",
+ "orientation": "horizontal",
+ "reduceOptions": {
+ "calcs": [
+ "lastNotNull"
+ ],
+ "fields": "",
+ "values": false
+ },
+ "showPercentChange": false,
+ "textMode": "auto",
+ "wideLayout": true
+ },
+ "pluginVersion": "11.0.0",
+ "repeatDirection": "h",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "avg(probe_dns_lookup_time_seconds{svc_kind=\"ssh\", svc_name=\"$target\"})",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "title": "Average DNS Lookup",
+ "type": "stat"
+ },
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "fieldConfig": {
+ "defaults": {
+ "color": {
+ "mode": "thresholds"
+ },
+ "custom": {
+ "axisBorderShow": false,
+ "axisCenteredZero": false,
+ "axisColorMode": "text",
+ "axisLabel": "",
+ "axisPlacement": "auto",
+ "axisSoftMin": 0,
+ "barAlignment": 0,
+ "drawStyle": "line",
+ "fillOpacity": 10,
+ "gradientMode": "scheme",
+ "hideFrom": {
+ "legend": false,
+ "tooltip": false,
+ "viz": false
+ },
+ "insertNulls": false,
+ "lineInterpolation": "linear",
+ "lineWidth": 1,
+ "pointSize": 5,
+ "scaleDistribution": {
+ "type": "linear"
+ },
+ "showPoints": "never",
+ "spanNulls": false,
+ "stacking": {
+ "group": "A",
+ "mode": "none"
+ },
+ "thresholdsStyle": {
+ "mode": "off"
+ }
+ },
+ "mappings": [],
+ "thresholds": {
+ "mode": "absolute",
+ "steps": [
+ {
+ "color": "green",
+ "value": null
+ },
+ {
+ "color": "orange",
+ "value": 0.2
+ },
+ {
+ "color": "red",
+ "value": 1
+ }
+ ]
+ },
+ "unit": "s"
+ },
+ "overrides": []
+ },
+ "gridPos": {
+ "h": 3,
+ "w": 12,
+ "x": 12,
+ "y": 9
+ },
+ "id": 17,
+ "options": {
+ "legend": {
+ "calcs": [],
+ "displayMode": "list",
+ "placement": "bottom",
+ "showLegend": false
+ },
+ "tooltip": {
+ "maxHeight": 600,
+ "mode": "multi",
+ "sort": "none"
+ }
+ },
+ "pluginVersion": "10.4.0",
+ "targets": [
+ {
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "editorMode": "code",
+ "expr": "probe_duration_seconds{svc_kind=\"ssh\", svc_name=\"$target\"}",
+ "format": "time_series",
+ "interval": "$interval",
+ "intervalFactor": 1,
+ "legendFormat": "seconds",
+ "range": true,
+ "refId": "A"
+ }
+ ],
+ "type": "timeseries"
+ }
+ ],
+ "refresh": "10s",
+ "schemaVersion": 39,
+ "tags": [
+ "blackbox",
+ "prometheus"
+ ],
+ "templating": {
+ "list": [
+ {
+ "auto": true,
+ "auto_count": 10,
+ "auto_min": "10s",
+ "current": {
+ "selected": false,
+ "text": "10s",
+ "value": "10s"
+ },
+ "hide": 0,
+ "label": "Interval",
+ "name": "interval",
+ "options": [
+ {
+ "selected": false,
+ "text": "auto",
+ "value": "$__auto_interval_interval"
+ },
+ {
+ "selected": false,
+ "text": "5s",
+ "value": "5s"
+ },
+ {
+ "selected": true,
+ "text": "10s",
+ "value": "10s"
+ },
+ {
+ "selected": false,
+ "text": "30s",
+ "value": "30s"
+ },
+ {
+ "selected": false,
+ "text": "1m",
+ "value": "1m"
+ },
+ {
+ "selected": false,
+ "text": "10m",
+ "value": "10m"
+ },
+ {
+ "selected": false,
+ "text": "30m",
+ "value": "30m"
+ },
+ {
+ "selected": false,
+ "text": "1h",
+ "value": "1h"
+ },
+ {
+ "selected": false,
+ "text": "6h",
+ "value": "6h"
+ },
+ {
+ "selected": false,
+ "text": "12h",
+ "value": "12h"
+ },
+ {
+ "selected": false,
+ "text": "1d",
+ "value": "1d"
+ },
+ {
+ "selected": false,
+ "text": "7d",
+ "value": "7d"
+ },
+ {
+ "selected": false,
+ "text": "14d",
+ "value": "14d"
+ },
+ {
+ "selected": false,
+ "text": "30d",
+ "value": "30d"
+ }
+ ],
+ "query": "5s,10s,30s,1m,10m,30m,1h,6h,12h,1d,7d,14d,30d",
+ "queryValue": "",
+ "refresh": 2,
+ "skipUrlSync": false,
+ "type": "interval"
+ },
+ {
+ "current": {},
+ "datasource": {
+ "type": "prometheus",
+ "uid": "${DS_PROMETHEUS}"
+ },
+ "definition": "label_values(probe_success{svc_kind=\"ssh\"},svc_name)",
+ "hide": 0,
+ "includeAll": true,
+ "multi": true,
+ "name": "target",
+ "options": [],
+ "query": {
+ "qryType": 1,
+ "query": "label_values(probe_success{svc_kind=\"ssh\"},svc_name)",
+ "refId": "PrometheusVariableQueryEditor-VariableQuery"
+ },
+ "refresh": 1,
+ "regex": "",
+ "skipUrlSync": false,
+ "sort": 0,
+ "tagValuesQuery": "",
+ "tagsQuery": "",
+ "type": "query",
+ "useTags": false
+ }
+ ]
+ },
+ "time": {
+ "from": "now-6h",
+ "to": "now"
+ },
+ "timeRangeUpdatedDuringEditOrView": false,
+ "timepicker": {
+ "refresh_intervals": [
+ "5s",
+ "10s",
+ "30s",
+ "1m",
+ "5m",
+ "15m",
+ "30m",
+ "1h",
+ "2h",
+ "1d"
+ ],
+ "time_options": [
+ "5m",
+ "15m",
+ "1h",
+ "6h",
+ "12h",
+ "24h",
+ "2d",
+ "7d",
+ "30d"
+ ]
+ },
+ "timezone": "",
+ "title": "ssh",
+ "uid": "fdp9xih70k7pce",
+ "version": 8,
+ "weekStart": ""
+}
diff --git a/roles/monitoring/grafana/filter_plugins/grafana.py b/roles/monitoring/grafana/filter_plugins/grafana.py
index 750dc46d..9fb78734 100644
--- a/roles/monitoring/grafana/filter_plugins/grafana.py
+++ b/roles/monitoring/grafana/filter_plugins/grafana.py
@@ -1,6 +1,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
+import os
from functools import partial
from ansible import errors
@@ -22,10 +23,40 @@ def resolve_grafana_url(url, config):
raise errors.AnsibleFilterError("resolve_grafana_url(): %s" % str(e))
+def grafana_dashboard_subdirs(dashboards):
+ try:
+ dirs = []
+ for dashboard in dashboards:
+ if 'file' in dashboard:
+ if '/' in dashboard['file']:
+ dirs.append(os.path.dirname(dashboard['file']))
+ else:
+ if '/' in dashboard['name']:
+ dirs.append(os.path.dirname(dashboard['name']))
+ return dirs
+ except Exception as e:
+ raise errors.AnsibleFilterError("grafana_dashboard_subdirs(): %s" % str(e))
+
+
+def grafana_dashboard_dest(dashboard):
+ try:
+ key = 'name'
+ if 'file' in dashboard:
+ key = 'file'
+
+ if '/' in dashboard[key]:
+ return "%s/%s_%s" % (os.path.dirname(dashboard[key]), dashboard['datasource'], os.path.basename(dashboard[key]))
+ return "%s_%s" % (dashboard['datasource'], dashboard[key])
+ except Exception as e:
+ raise errors.AnsibleFilterError("grafana_dashboard_dest(): %s" % str(e))
+
+
class FilterModule(object):
filter_map = {
'resolve_grafana_url': resolve_grafana_url,
+ 'grafana_dashboard_subdirs': grafana_dashboard_subdirs,
+ 'grafana_dashboard_dest': grafana_dashboard_dest,
}
def filters(self):
diff --git a/roles/monitoring/grafana/tasks/main.yml b/roles/monitoring/grafana/tasks/main.yml
index de2857df..5d6c9c17 100644
--- a/roles/monitoring/grafana/tasks/main.yml
+++ b/roles/monitoring/grafana/tasks/main.yml
@@ -118,20 +118,28 @@
mode: 0640
notify: restart grafana
-- name: create directory for dashboards
+- name: create base directory for dashboards
file:
path: /var/lib/grafana/dashboards/ansible
state: directory
group: grafana
mode: 0750
+- name: create sub-directories for dashboards
+ loop: "{{ grafana_dashboards | grafana_dashboard_subdirs }}"
+ file:
+ path: "/var/lib/grafana/dashboards/ansible/{{ item }}"
+ state: directory
+ group: grafana
+ mode: 0750
+
- name: install dashboards from file
loop: "{{ grafana_dashboards | selectattr('file', 'defined') }}"
loop_control:
label: "{{ item.file }} -> {{ item.datasource }}"
copy:
content: "{{ lookup('file', 'dashboard-'+item.file+'.json') | regex_replace('\"(?:\\${)?DS_[A-Z0-9_-]+(?:})?\"', '\"'+item.datasource+'\"') }}\n"
- dest: "/var/lib/grafana/dashboards/ansible/{{ item.datasource }}_{{ item.file }}.json"
+ dest: "/var/lib/grafana/dashboards/ansible/{{ item | grafana_dashboard_dest }}.json"
register: grafana_dasboards_from_file
- name: install dashboards from content
@@ -140,22 +148,14 @@
label: "{{ item.name }} -> {{ item.datasource }}"
copy:
content: "{{ item.content | regex_replace('\"(?:\\${)?DS_[A-Z0-9_-]+(?:})?\"', '\"'+item.datasource+'\"') }}\n"
- dest: "/var/lib/grafana/dashboards/ansible/{{ item.datasource }}_{{ item.name }}.json"
+ dest: "/var/lib/grafana/dashboards/ansible/{{ item | grafana_dashboard_dest }}.json"
register: grafana_dasboards_from_content
- ## TODO: implement this
-- name: install dashboards from grafana.com
- loop: "{{ grafana_dashboards | selectattr('id', 'defined') }}"
- loop_control:
- label: "https://grafana.com/api/dashboards/{{ item.id }} -> {{ item.datasource }}"
- debug:
- msg: 'installing dashboards from grafana.com is not yet supported!'
- # register: grafana_dasboards_from_grafanacom
-
- name: fetch list of installed dashboards
find:
paths: /var/lib/grafana/dashboards/ansible
patterns: "*.json"
+ recurse: true
register: grafana_dashboards_installed
- name: remove superfluous dashboards