commit 236bee37fa207e76514b4e010042a47f16ae732f
parent 52be2228f0de6ab2352789e4474029b7225d80fa
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:00:46 +0100
parent 52be2228f0de6ab2352789e4474029b7225d80fa
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 22 Feb 2021 17:00:46 +0100
roles/grafana: use handlers for restart, better handling of provisioning
20 files changed, 1958 insertions(+), 667 deletions(-)
A
|
1810
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
R
|
0
D
|
568
-------------------------------------------------------------------------------
D
|
50
--------------------------------------------------
A
|
69
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/config-files/grafana/dashboards/SmartHome.json b/config-files/grafana/dashboards/SmartHome.json @@ -0,0 +1,1809 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 21, + "links": [], + "panels": [ + { + "datasource": "InfluxDB (Sensors)", + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "max": 30, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 9 + }, + { + "color": "red", + "value": 23 + } + ] + }, + "unit": "celsius" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 0, + "y": 0 + }, + "id": 16, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Bad", + "groupBy": [], + "measurement": "lacrosse-bad", + "orderByTime": "ASC", + "policy": "autogen", + "query": "SELECT mean(\"value\") FROM \"sensors\".\"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Bad", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Powermeters)", + "description": "", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 2, + "mappings": [], + "max": 260, + "min": 220, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "yellow", + "value": null + }, + { + "color": "red", + "value": 200 + }, + { + "color": "green", + "value": 230 + }, + { + "color": "red", + "value": 250 + } + ] + }, + "unit": "volt" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 3, + "y": 0 + }, + "id": 4, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "voltage" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "voltage" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Voltage", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Powermeters)", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 2, + "mappings": [], + "max": 51, + "min": 49, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "rothz" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 6, + "y": 0 + }, + "id": 6, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "frequency" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "frequency" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Frequency", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Powermeters)", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 2, + "mappings": [], + "max": 16, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 10 + } + ] + }, + "unit": "amp" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 9, + "y": 0 + }, + "id": 8, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "current" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "current" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Current", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Powermeters)", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 3, + "mappings": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 0.8 + } + ] + }, + "unit": "φ" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 12, + "y": 0 + }, + "id": 10, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cosphi" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "cosphi" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Power Factor", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Powermeters)", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 2, + "mappings": [], + "max": 3600, + "min": 0, + "thresholds": { + "mode": "percentage", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "yellow", + "value": 30 + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "watt" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 15, + "y": 0 + }, + "id": 12, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "power" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "power" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Power", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Powermeters)", + "fieldConfig": { + "defaults": { + "custom": {}, + "decimals": 1, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgb(237, 237, 237)", + "value": null + } + ] + }, + "unit": "kwatth" + }, + "overrides": [] + }, + "gridPos": { + "h": 9, + "w": 3, + "x": 18, + "y": 0 + }, + "id": 14, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "center", + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "textMode": "value_and_name" + }, + "pluginVersion": "", + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "import" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "import" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Imported", + "transparent": true, + "type": "stat" + }, + { + "datasource": "InfluxDB (Sensors)", + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "max": 10, + "min": 3, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 5 + }, + { + "color": "red", + "value": 8 + } + ] + }, + "unit": "celsius" + }, + "overrides": [] + }, + "gridPos": { + "h": 4, + "w": 3, + "x": 21, + "y": 0 + }, + "id": 17, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "", + "groupBy": [], + "measurement": "lacrosse-kuehlschrank", + "orderByTime": "ASC", + "policy": "autogen", + "query": "SELECT mean(\"value\") FROM \"sensors\".\"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Kühlschrank", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Sensors)", + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "max": 30, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 9 + }, + { + "color": "red", + "value": 23 + } + ] + }, + "unit": "celsius" + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 3, + "x": 0, + "y": 4 + }, + "id": 22, + "options": { + "orientation": "auto", + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "", + "groupBy": [], + "measurement": "lacrosse-raum", + "orderByTime": "ASC", + "policy": "autogen", + "query": "SELECT last(\"temperature\") FROM \"autogen\".\"lacrosse-raum\" WHERE $timeFilter", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Zimmer", + "transparent": true, + "type": "gauge" + }, + { + "datasource": "InfluxDB (Sensors)", + "fieldConfig": { + "defaults": { + "custom": {}, + "mappings": [], + "max": 30, + "min": -8, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + }, + { + "color": "green", + "value": 5 + }, + { + "color": "red", + "value": 25 + } + ] + }, + "unit": "celsius" + }, + "overrides": [] + }, + "gridPos": { + "h": 5, + "w": 3, + "x": 21, + "y": 4 + }, + "id": 19, + "options": { + "reduceOptions": { + "calcs": [ + "lastNotNull" + ], + "fields": "", + "values": false + }, + "showThresholdLabels": false, + "showThresholdMarkers": true + }, + "pluginVersion": "", + "targets": [ + { + "alias": "", + "groupBy": [], + "measurement": "lacrosse-draussen", + "orderByTime": "ASC", + "policy": "autogen", + "query": "SELECT mean(\"value\") FROM \"sensors\".\"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "last" + } + ] + ], + "tags": [] + } + ], + "timeFrom": null, + "timeShift": null, + "title": "Draußen", + "transparent": true, + "type": "gauge" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB (Powermeters)", + "description": "", + "fieldConfig": { + "defaults": { + "custom": {}, + "unit": "watt" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 9 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "power" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\") FROM \"modbus-60\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "rawQuery": false, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "power" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Power Consumption", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:162", + "format": "watt", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:163", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB (Powermeters)", + "fieldConfig": { + "defaults": { + "custom": {}, + "unit": "volt" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 12, + "x": 12, + "y": 9 + }, + "hiddenSeries": false, + "id": 24, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Sonstiges", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "modbus-50", + "orderByTime": "ASC", + "policy": "default", + "queryType": "randomWalk", + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "voltage" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Küche", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "modbus-60", + "orderByTime": "ASC", + "policy": "default", + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "voltage" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Voltage", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:513", + "format": "volt", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:514", + "decimals": 1, + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB (Sensors)", + "fieldConfig": { + "defaults": { + "custom": {}, + "unit": "celsius" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 16 + }, + "hiddenSeries": false, + "id": 26, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Bad", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-bad", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\") FROM \"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Draußen", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-draussen", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\") FROM \"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Kühlschrank", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-kuehlschrank", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"temperature\") FROM \"lacrosse-kuehlschrank\" WHERE $timeFilter GROUP BY time($__interval) fill(linear)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Zimmer", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-raum", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"temperature\") FROM \"lacrosse-kuehlschrank\" WHERE $timeFilter GROUP BY time($__interval) fill(linear)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "temperature" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Temperature", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:997", + "format": "celsius", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:998", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "InfluxDB (Sensors)", + "fieldConfig": { + "defaults": { + "custom": {}, + "unit": "humidity" + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 16 + }, + "hiddenSeries": false, + "id": 27, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "", + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Bad", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-bad", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\") FROM \"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "A", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "humidity" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Draußen", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-draussen", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"value\") FROM \"measurement\" WHERE $timeFilter GROUP BY time($__interval) fill(null)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "humidity" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + }, + { + "alias": "Zimmer", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "linear" + ], + "type": "fill" + } + ], + "measurement": "lacrosse-raum", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT mean(\"temperature\") FROM \"lacrosse-kuehlschrank\" WHERE $timeFilter GROUP BY time($__interval) fill(linear)", + "queryType": "randomWalk", + "rawQuery": false, + "refId": "D", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "humidity" + ], + "type": "field" + }, + { + "params": [], + "type": "mean" + } + ] + ], + "tags": [] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Humidity", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "$$hashKey": "object:997", + "format": "humidity", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + }, + { + "$$hashKey": "object:998", + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": true + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + } + ], + "refresh": "5s", + "schemaVersion": 26, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "SmartHome (Influx)", + "uid": "FRDYqjEGz", + "version": 18 +}+ \ No newline at end of file
diff --git a/config-files/grafana/provisioning/dashboards/dashboards.yml b/config-files/grafana/provisioning/dashboards/dashboards.yml @@ -1,11 +0,0 @@ -apiVersion: 1 - -providers: -- name: 'Prometheus' - orgId: 1 - folder: '' - type: file - disableDeletion: false - editable: false - options: - path: /var/lib/grafana/provisioning/dashboards
diff --git a/config-files/grafana/provisioning/dashboards/smarthome.json b/config-files/grafana/provisioning/dashboards/smarthome.json @@ -1,568 +0,0 @@ -{ - "annotations": { - "list": [ - { - "builtIn": 1, - "datasource": "-- Grafana --", - "enable": true, - "hide": true, - "iconColor": "rgba(0, 211, 255, 1)", - "name": "Annotations & Alerts", - "type": "dashboard" - } - ] - }, - "editable": true, - "gnetId": null, - "graphTooltip": 0, - "id": 3, - "links": [], - "panels": [ - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "fill": 10, - "fillGradient": 0, - "gridPos": { - "h": 9, - "w": 24, - "x": 0, - "y": 0 - }, - "hiddenSeries": false, - "id": 2, - "legend": { - "avg": false, - "current": false, - "hideEmpty": false, - "hideZero": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 0, - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "powermeter_power", - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Power Usage", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "watt", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "cacheTimeout": null, - "datasource": "Prometheus", - "gridPos": { - "h": 4, - "w": 15, - "x": 0, - "y": 9 - }, - "id": 10, - "links": [], - "options": { - "fieldOptions": { - "calcs": [ - "last" - ], - "defaults": { - "mappings": [ - { - "id": 0, - "op": "=", - "text": "on", - "type": 1, - "value": "1" - }, - { - "from": "", - "id": 1, - "operator": "", - "text": "off", - "to": "", - "type": 1, - "value": "0" - } - ], - "max": 1, - "min": 0, - "nullValueMode": "connected", - "thresholds": [ - { - "color": "green", - "value": null - }, - { - "color": "red", - "value": 80 - } - ], - "unit": "none" - }, - "override": {}, - "values": false - }, - "orientation": "horizontal", - "showThresholdLabels": false, - "showThresholdMarkers": false - }, - "pluginVersion": "6.5.2", - "targets": [ - { - "expr": "relayboard_relay", - "format": "time_series", - "legendFormat": "relay {{ relay }}", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Relays", - "type": "gauge" - }, - { - "datasource": "Prometheus", - "gridPos": { - "h": 4, - "w": 3, - "x": 15, - "y": 9 - }, - "id": 12, - "options": { - "fieldOptions": { - "calcs": [ - "last" - ], - "defaults": { - "mappings": [], - "max": 4000, - "min": 0, - "thresholds": [ - { - "color": "green", - "value": null - }, - { - "color": "#EAB839", - "value": 1000 - }, - { - "color": "dark-red", - "value": 3000 - } - ], - "unit": "watt" - }, - "override": {}, - "values": false - }, - "orientation": "auto", - "showThresholdLabels": false, - "showThresholdMarkers": true - }, - "pluginVersion": "6.5.2", - "targets": [ - { - "expr": "sum(powermeter_power)", - "refId": "A" - } - ], - "timeFrom": null, - "timeShift": null, - "title": "Current Power Usage", - "type": "gauge" - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 0, - "y": 13 - }, - "hiddenSeries": false, - "id": 6, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "lacrossetempsensor_humidity > 0", - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Humidity", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "humidity", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "aliasColors": {}, - "bars": false, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 8, - "w": 12, - "x": 12, - "y": 13 - }, - "hiddenSeries": false, - "id": 4, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": true, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": false, - "steppedLine": false, - "targets": [ - { - "expr": "lacrossetempsensor_temperature", - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": null, - "timeRegions": [], - "timeShift": null, - "title": "Temperature", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "celsius", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - }, - { - "columns": [], - "datasource": "Prometheus", - "fontSize": "100%", - "gridPos": { - "h": 9, - "w": 6, - "x": 0, - "y": 21 - }, - "id": 20, - "options": {}, - "pageSize": null, - "showHeader": true, - "sort": { - "col": 0, - "desc": true - }, - "styles": [ - { - "alias": "Time", - "dateFormat": "YYYY-MM-DD HH:mm:ss", - "pattern": "Time", - "type": "date" - }, - { - "alias": "", - "colorMode": null, - "colors": [ - "rgba(245, 54, 54, 0.9)", - "rgba(237, 129, 40, 0.89)", - "rgba(50, 172, 45, 0.97)" - ], - "decimals": 2, - "pattern": "/.*/", - "thresholds": [], - "type": "number", - "unit": "short" - } - ], - "targets": [ - { - "expr": "increase(powermeter_import[1d])", - "interval": "1d", - "legendFormat": "{{device}}", - "refId": "A" - } - ], - "timeFrom": "7d", - "timeShift": null, - "title": "Power Usage History (per day)", - "transform": "timeseries_to_columns", - "type": "table" - }, - { - "aliasColors": {}, - "bars": true, - "dashLength": 10, - "dashes": false, - "datasource": "Prometheus", - "fill": 1, - "fillGradient": 0, - "gridPos": { - "h": 9, - "w": 18, - "x": 6, - "y": 21 - }, - "hiddenSeries": false, - "id": 22, - "legend": { - "avg": false, - "current": false, - "max": false, - "min": false, - "show": true, - "total": false, - "values": false - }, - "lines": false, - "linewidth": 1, - "nullPointMode": "null", - "options": { - "dataLinks": [] - }, - "percentage": false, - "pluginVersion": "6.5.2", - "pointradius": 2, - "points": false, - "renderer": "flot", - "seriesOverrides": [], - "spaceLength": 10, - "stack": true, - "steppedLine": false, - "targets": [ - { - "expr": "increase(powermeter_import[1h])", - "interval": "1h", - "legendFormat": "{{ device }}", - "refId": "A" - } - ], - "thresholds": [], - "timeFrom": "1d", - "timeRegions": [], - "timeShift": null, - "title": "Power Usage History (per hour)", - "tooltip": { - "shared": true, - "sort": 0, - "value_type": "individual" - }, - "type": "graph", - "xaxis": { - "buckets": null, - "mode": "time", - "name": null, - "show": true, - "values": [] - }, - "yaxes": [ - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - }, - { - "format": "short", - "label": null, - "logBase": 1, - "max": null, - "min": null, - "show": true - } - ], - "yaxis": { - "align": false, - "alignLevel": null - } - } - ], - "refresh": "30s", - "schemaVersion": 21, - "style": "dark", - "tags": [], - "templating": { - "list": [] - }, - "time": { - "from": "now-6h", - "to": "now" - }, - "timepicker": {}, - "timezone": "", - "title": "SmartHome", - "uid": "j6KLQ-LZz", - "version": 37 -}
diff --git a/config-files/grafana/provisioning/datasources/datasources.yml b/config-files/grafana/provisioning/datasources/datasources.yml @@ -1,50 +0,0 @@ -# config file version -apiVersion: 1 - -# list of datasources that should be deleted from the database -deleteDatasources: - - name: Prometheus - orgId: 1 - -# list of datasources to insert/update depending -# whats available in the database -datasources: - # <string, required> name of the datasource. Required -- name: Prometheus - # <string, required> datasource type. Required - type: prometheus - # <string, required> access mode. direct or proxy. Required - access: proxy - # <int> org id. will default to orgId 1 if not specified - orgId: 1 - # <string> url - url: http://127.0.0.1:9090 - # <string> database password, if used - password: - # <string> database user, if used - user: - # <string> database name, if used - database: - # <bool> enable/disable basic auth - basicAuth: true - # <string> basic auth username - basicAuthUser: admin - # <string> basic auth password - basicAuthPassword: foobar - # <bool> enable/disable with credentials headers - withCredentials: - # <bool> mark as default datasource. Max one per org - isDefault: - # <map> fields that will be converted to json and stored in json_data - jsonData: - graphiteVersion: "1.1" - tlsAuth: false - tlsAuthWithCACert: false - # <string> json object of data that will be encrypted. - secureJsonData: - tlsCACert: "..." - tlsClientCert: "..." - tlsClientKey: "..." - version: 1 - # <bool> allow users to edit datasources from the UI. - editable: true
diff --git a/roles/grafana/handlers/main.yml b/roles/grafana/handlers/main.yml @@ -0,0 +1,24 @@ +--- + +- name: "Delete file: /var/lib/grafana/data/grafana.db" + file: + name: /var/lib/grafana/data/grafana.db + state: absent + listen: "Delete database and restart grafana" + notify: "Restart grafana" + +- name: "[OpenRC] Restart service: grafana (to deploy config changes)" + service: + name: grafana + state: restarted + when: + - ansible_service_mgr == "openrc" + listen: "Restart grafana" + +- name: "[systemd] Restart service: grafana (to deploy config changes)" + systemd: + name: grafana + state: restarted + when: + - ansible_service_mgr == "systemd" + listen: "Restart grafana"
diff --git a/roles/grafana/meta/main.yml b/roles/grafana/meta/main.yml @@ -0,0 +1,6 @@ +--- + +dependencies: + - role: nginx + when: + - services.grafana.nginx.enable is true
diff --git a/roles/grafana/tasks/checks.yml b/roles/grafana/tasks/checks.yml @@ -4,6 +4,16 @@ when: - services.grafana.configFile is not defined +- fail: msg="Option 'services.grafana.dashboards' has to be set when using provisioning!" + when: + - services.grafana.provisioning.enable is true + - services.grafana.provisioning.dashboards is not defined + +- fail: msg="Option 'services.grafana.datasources' has to be set when using provisioning!" + when: + - services.grafana.provisioning.enable is true + - services.grafana.provisioning.datasources is not defined + - fail: msg="Nginx role has to be enabled when using nginx options!" when: - services.grafana.nginx.enable is true
diff --git a/roles/grafana/tasks/configure.yml b/roles/grafana/tasks/configure.yml @@ -5,18 +5,4 @@ src: "{{ services.grafana.configFile }}" dest: /etc/grafana.ini mode: 0755 - -- name: "Remove directory: /var/lib/grafana/provisioning" - file: - path: /var/lib/grafana/provisioning - state: absent - -- name: "Copy provisioning data to: /var/lib/grafana/provisioning" - copy: - src: "{{ services.grafana.provisioningPath }}" - dest: /var/lib/grafana/ - mode: 0755 - owner: grafana - group: grafana - when: - - services.grafana.provisioningPath is defined- \ No newline at end of file + notify: "Restart grafana"
diff --git a/roles/grafana/tasks/install.yml b/roles/grafana/tasks/install.yml @@ -4,7 +4,6 @@ apk: name: grafana state: present - update_cache: yes when: - ansible_distribution == "Alpine" @@ -12,6 +11,5 @@ pacman: name: grafana state: present - update_cache: yes when: - ansible_distribution == "Archlinux"
diff --git a/roles/grafana/tasks/main.yml b/roles/grafana/tasks/main.yml @@ -15,6 +15,13 @@ - services.grafana.enable is defined - services.grafana.enable is true +- include: provisioning.yml + when: + - services.grafana.enable is defined + - services.grafana.enable is true + - services.grafana.provisioning.enable is defined + - services.grafana.provisioning.enable is true + - include: start.yml when: - services.grafana.enable is defined @@ -32,6 +39,8 @@ - services.grafana.enable is defined - services.grafana.enable is false +- name: Run handlers + meta: flush_handlers
diff --git a/roles/grafana/tasks/nginx.yml b/roles/grafana/tasks/nginx.yml @@ -7,17 +7,4 @@ mode: 0644 owner: nginx group: nginx - -- name: "[OpenRC] Restart service: nginx" - service: - name: nginx - state: restarted - when: - - ansible_service_mgr == "openrc" - -- name: "[systemd] Restart service: nginx" - systemd: - name: nginx - state: restarted - when: - - ansible_service_mgr == "systemd" + notify: "Restart nginx"+ \ No newline at end of file
diff --git a/roles/grafana/tasks/provisioning.yml b/roles/grafana/tasks/provisioning.yml @@ -0,0 +1,69 @@ +--- + +- name: "Create directorys needed for provisioning" + file: + state: directory + dest: "{{ item }}" + mode: 0755 + owner: grafana + group: grafana + with_items: + - /var/lib/grafana + - /var/lib/grafana/provisioning + - /var/lib/grafana/provisioning/dashboards + - /var/lib/grafana/provisioning/datasources + notify: "Restart grafana" + +- name: "Copy dashboards jsons to: /var/lib/grafana/provisioning/dashboards" + copy: + src: "{{ services.grafana.provisioning.dashboards }}/" + dest: /var/lib/grafana/provisioning/dashboards + mode: 0755 + owner: grafana + group: grafana + notify: "Restart grafana" + +- name: "Generate /var/lib/grafana/provisioning/datasources/datasources.yml" + template: + src: datasources.yml.j2 + dest: /var/lib/grafana/provisioning/datasources/datasources.yml + mode: 0755 + owner: grafana + group: grafana + notify: "Delete database and restart grafana" + +- name: "Generate file: /var/lib/grafana/provisioning/dashboards/dashboards.yml" + template: + src: dashboards.yml.j2 + dest: /var/lib/grafana/provisioning/dashboards/dashboards.yml + mode: 0755 + owner: grafana + group: grafana + + +- name: "Collect files in directory: /var/lib/grafana/provisioning/dashboards" + find: + path: /var/lib/grafana/provisioning/dashboards + hidden: yes + register: grafana_dashboards_remote + check_mode: no + changed_when: false + +- name: "Collect files in local directory: {{ services.grafana.provisioning.dashboards }}" + local_action: + module: find + path: "{{ services.grafana.provisioning.dashboards }}" + hidden: yes + register: grafana_dashboards_local + check_mode: no + changed_when: false + +- name: "Remove unmanaged files in directory: /var/lib/grafana/provisioning/dashboards" + file: + path: "/var/lib/grafana/provisioning/dashboards/{{ item.path | basename }}" + state: absent + with_items: + - "{{ grafana_dashboards_remote.files }}" + notify: "Delete database and restart grafana" + when: + - (item.path | basename) != "dashboards.yml" and (item.path | basename) not in (grafana_dashboards_local.files | map(attribute="path") | map("basename") | list)
diff --git a/roles/grafana/tasks/remove.yml b/roles/grafana/tasks/remove.yml @@ -37,4 +37,10 @@ with_items: - /etc/nginx/conf.d/grafana.conf - /etc/grafana.ini - - /var/lib/grafana/provisioning- \ No newline at end of file + - /var/lib/grafana/provisioning + +- name: "Delete nginx vhost for: grafana" + file: + path: /etc/nginx/conf.d/grafana.conf + state: absent + notify: "Restart nginx"
diff --git a/roles/grafana/tasks/start.yml b/roles/grafana/tasks/start.yml @@ -1,17 +1,17 @@ --- -- name: "[OpenRC] Restart and enable service: grafana" +- name: "[OpenRC] Start and enable service: grafana" service: name: grafana enabled: yes - state: restarted + state: started when: - ansible_service_mgr == "openrc" -- name: "[systemd] Restart and enable service: grafana" +- name: "[systemd] Start and enable service: grafana" systemd: name: grafana enabled: yes - state: restarted + state: started when: - ansible_service_mgr == "systemd" \ No newline at end of file
diff --git a/roles/grafana/templates/dashboards.yml.j2 b/roles/grafana/templates/dashboards.yml.j2 @@ -0,0 +1,11 @@ +apiVersion: 1 + +providers: +- name: 'Dashboards' + orgId: 1 + folder: '' + type: file + disableDeletion: true + editable: true + options: + path: /var/lib/grafana/provisioning/dashboards
diff --git a/roles/grafana/templates/datasources.yml.j2 b/roles/grafana/templates/datasources.yml.j2 @@ -0,0 +1,4 @@ +apiVersion: 1 + +datasources: +{{ services.grafana.provisioning.datasources | to_nice_yaml(indent=2) | indent(2, true) }}+ \ No newline at end of file