monitoring: automagically provision grafana

This commit is contained in:
Gregor Michels 2022-09-04 18:56:20 +02:00
parent 6e108868cb
commit 67ebf9b9bb
5 changed files with 14881 additions and 0 deletions

View File

@ -89,6 +89,48 @@
notify:
- restart grafana
- name: template grafana datasource provisioning
template:
src: "{{ item }}"
dest: /etc/grafana/provisioning/datasources/
owner: root
group: grafana
mode: 0640
with_fileglob:
- "templates/grafana/provisioning/datasources/*"
notify:
- restart grafana
- name: create /etc/grafana/dashboards
file:
path: /etc/grafana/dashboards
state: directory
owner: root
group: grafana
mode: 0755
- name: install dashboards
copy:
src: "{{ item }}"
dest: /etc/grafana/dashboards/
owner: root
group: grafana
mode: 0640
with_fileglob:
- "templates/grafana/dashboards/*"
- name: template grafana dashboard provisioning
copy:
src: "{{ item }}"
dest: /etc/grafana/provisioning/dashboards/
owner: root
group: grafana
mode: 0644
with_fileglob:
- "templates/grafana/provisioning/dashboards/*"
notify:
- restart grafana
handlers:
- name: reload prometheus
service:

View File

@ -0,0 +1,703 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"links": [],
"liveNow": false,
"panels": [
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 0
},
"id": 2,
"panels": [],
"title": "Status",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"description": "how many devices are up",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"min": 0,
"noValue": "-",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "transparent",
"value": null
}
]
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "accesspoints"
},
"properties": [
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "#EAB839",
"value": 1
},
{
"color": "green",
"value": 6
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "gateways"
},
"properties": [
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "switches"
},
"properties": [
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "#EAB839",
"value": 1
},
{
"color": "green",
"value": 2
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "server"
},
"properties": [
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "vms"
},
"properties": [
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "#EAB839",
"value": 1
},
{
"color": "green",
"value": 2
}
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "prometheus"
},
"properties": [
{
"id": "thresholds",
"value": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 1
}
]
}
}
]
}
]
},
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 1
},
"id": 4,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"last"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "9.0.4",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_PROMETHEUS}"
},
"editorMode": "code",
"expr": "sum by (job) (up)",
"legendFormat": "__auto",
"range": true,
"refId": "A"
}
],
"title": "availability of devices",
"type": "stat"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 9
},
"id": 15,
"panels": [],
"title": "Internet",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"description": "all traffic routed into the internet",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "decbytes"
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "switch.3"
},
"properties": [
{
"id": "displayName",
"value": "overall (w. backoffice)"
}
]
},
{
"matcher": {
"id": "byName",
"options": "wg1"
},
"properties": [
{
"id": "displayName",
"value": "public wifi"
}
]
},
{
"matcher": {
"id": "byName",
"options": "wg0"
},
"properties": [
{
"id": "displayName",
"value": "management"
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 10
},
"id": 8,
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto"
},
"pluginVersion": "9.0.4",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"editorMode": "code",
"expr": "increase(node_network_receive_bytes_total{instance=\"gw-core01:9100\",device=~\"switch.3|wg1|wg0\"}[$__range]) + increase(node_network_transmit_bytes_total{instance=\"gw-core01:9100\",device=~\"switch.3|wg1|wg0\"}[$__range])",
"legendFormat": "{{device}}",
"range": true,
"refId": "A"
}
],
"title": "used bandwidth in time series",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"description": "all traffic routed into the internet. Includes public wifi, backoffice and management",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 51,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "bps"
},
"overrides": [
{
"matcher": {
"id": "byRegexp",
"options": "/tx/"
},
"properties": [
{
"id": "custom.transform",
"value": "negative-Y"
}
]
}
]
},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 10
},
"id": 6,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"editorMode": "code",
"expr": "irate(node_network_receive_bytes_total{instance=\"gw-core01:9100\", device=~\"switch.3\"}[$__rate_interval]) * 8",
"legendFormat": "rx",
"range": true,
"refId": "A"
},
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"editorMode": "code",
"expr": "irate(node_network_transmit_bytes_total{instance=\"gw-core01:9100\", device=~\"switch.3\"}[$__rate_interval]) * 8",
"hide": false,
"legendFormat": "tx",
"range": true,
"refId": "B"
}
],
"title": "used Bandwidth",
"type": "timeseries"
},
{
"collapsed": false,
"gridPos": {
"h": 1,
"w": 24,
"x": 0,
"y": 17
},
"id": 12,
"panels": [],
"title": "WiFi",
"type": "row"
},
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"description": "how many wifi clients are connected to which network - 2,4 GhZ",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 18
},
"id": 10,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"editorMode": "code",
"expr": "sum (wifi_network_clients{ifname=~\"wlan0.*\"}) by (ssid)",
"legendFormat": "{{ ssid }}",
"range": true,
"refId": "A"
}
],
"title": "wifi clients 2,4 Ghz",
"type": "timeseries"
},
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"description": "how many wifi clients are connected to which network - 5 GhZ",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 12,
"y": 18
},
"id": 13,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "P1809F7CD0C75ACF3"
},
"editorMode": "code",
"expr": "sum (wifi_network_clients{ifname=~\"wlan1.*\"}) by (ssid)",
"legendFormat": "{{ ssid }}",
"range": true,
"refId": "A"
}
],
"title": "wifi clients 5 Ghz",
"type": "timeseries"
}
],
"schemaVersion": 36,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "EAE - Am Deutschen Platz - Network Statistics",
"uid": "Yz0oaZenz",
"version": 9,
"weekStart": ""
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: dashboards
type: file
updateIntervalSeconds: 30
allowUiUpdates: false
disableDeletion: true
options:
path: /etc/grafana/dashboards
foldersFromFilesStructure: true

View File

@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: prometheus
type: prometheus
access: proxy
url: http://{{ ip }}:9090
isDefault: True
editable: false