From 63eaf5b07211cafc15a7e2d4834c969bfd602a6d Mon Sep 17 00:00:00 2001 From: Patrick Stevens Date: Sat, 22 Jul 2023 09:42:37 +0100 Subject: [PATCH] Add Grafana dashboard (#15) --- PulumiWebServer/Nix/grafana/grafana.nix | 18 + PulumiWebServer/Nix/grafana/node.json | 558 +++++++++++++++++++++++ PulumiWebServer/Nix/secrets/staging.json | 6 +- PulumiWebServer/PulumiWebServer.fsproj | 1 + 4 files changed, 581 insertions(+), 2 deletions(-) create mode 100644 PulumiWebServer/Nix/grafana/node.json diff --git a/PulumiWebServer/Nix/grafana/grafana.nix b/PulumiWebServer/Nix/grafana/grafana.nix index 93900e3..e90feb5 100644 --- a/PulumiWebServer/Nix/grafana/grafana.nix +++ b/PulumiWebServer/Nix/grafana/grafana.nix @@ -34,6 +34,13 @@ }; }; + environment.etc."grafana-dashboards/node.json" = { + source = ./node.json; + group = "grafana"; + user = "grafana"; + mode = "0440"; + }; + services.grafana = { enable = true; settings = { @@ -69,6 +76,17 @@ ]; }; }; + dashboards = { + settings = { + apiVersion = 1; + providers = [ + { + name = "default"; + options.path = "/etc/grafana-dashboards"; + } + ]; + }; + }; }; }; }; diff --git a/PulumiWebServer/Nix/grafana/node.json b/PulumiWebServer/Nix/grafana/node.json new file mode 100644 index 0000000..cb48b58 --- /dev/null +++ b/PulumiWebServer/Nix/grafana/node.json @@ -0,0 +1,558 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "uid": "-- Grafana --" + }, + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "id": 1, + "links": [], + "liveNow": false, + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "description": "", + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "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": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 0 + }, + "id": 5, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "editorMode": "builder", + "exemplar": false, + "expr": "rate(node_cpu_seconds_total{mode!=\"idle\"}[5m])", + "hide": false, + "legendFormat": "{{mode}}", + "range": true, + "refId": "A" + } + ], + "title": "CPU usage", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "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": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "decbytes" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 0 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "editorMode": "builder", + "expr": "rate(node_network_receive_bytes_total{job=\"node\"}[5m])", + "legendFormat": "{{device}} (receive)", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "editorMode": "builder", + "expr": "rate(node_network_transmit_bytes_total{job=\"node\"}[5m])", + "hide": false, + "legendFormat": "{{device}} (send)", + "range": true, + "refId": "B" + } + ], + "title": "Network activity", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "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": [], + "max": 1, + "min": 0, + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "percentunit" + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 8 + }, + "id": 7, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "editorMode": "builder", + "expr": "node_filesystem_free_bytes / node_filesystem_size_bytes{job=\"node\"}", + "hide": false, + "legendFormat": "{{mountpoint}} ({{device}})", + "range": true, + "refId": "A" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "editorMode": "builder", + "expr": "node_filesystem_size_bytes{job=\"node\"}", + "hide": true, + "legendFormat": "{{mountpoint}} ({{device}})", + "range": true, + "refId": "B" + } + ], + "title": "Free disk", + "type": "timeseries" + }, + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisCenteredZero": false, + "axisColorMode": "text", + "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": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 8 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "P40645DF18AF953B4" + }, + "editorMode": "builder", + "expr": "rate(node_disk_io_time_seconds_total{job=\"node\"}[5m])", + "legendFormat": "{{device}}", + "range": true, + "refId": "A" + } + ], + "title": "Disk I/O", + "type": "timeseries" + }, + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 3, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 1, + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "type": "welcome" + }, + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 15, + "w": 12, + "x": 0, + "y": 19 + }, + "id": 3, + "links": [], + "options": { + "folderId": 0, + "maxItems": 30, + "query": "", + "showHeadings": true, + "showRecentlyViewed": true, + "showSearch": false, + "showStarred": true, + "tags": [] + }, + "pluginVersion": "9.5.2", + "tags": [], + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "Dashboards", + "type": "dashlist" + }, + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "gridPos": { + "h": 15, + "w": 12, + "x": 12, + "y": 19 + }, + "id": 4, + "links": [], + "options": { + "feedUrl": "https://grafana.com/blog/news.xml", + "showImage": true + }, + "targets": [ + { + "datasource": { + "type": "datasource", + "uid": "grafana" + }, + "refId": "A" + } + ], + "title": "Latest from the blog", + "type": "news" + } + ], + "refresh": "", + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-12h", + "to": "now" + }, + "timepicker": { + "hidden": true, + "refresh_intervals": [ + "5s", + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ], + "time_options": [ + "5m", + "15m", + "1h", + "6h", + "12h", + "24h", + "2d", + "7d", + "30d" + ], + "type": "timepicker" + }, + "timezone": "browser", + "title": "Node", + "uid": "d872af8a-0e64-4b22-8d97-7db77958960b", + "version": 3, + "weekStart": "" +} diff --git a/PulumiWebServer/Nix/secrets/staging.json b/PulumiWebServer/Nix/secrets/staging.json index 1e22344..657a567 100644 --- a/PulumiWebServer/Nix/secrets/staging.json +++ b/PulumiWebServer/Nix/secrets/staging.json @@ -11,6 +11,8 @@ "radicale_htcrypt_password": "ENC[AES256_GCM,data:vHHIiPjUjM4cQvv9acz8tFmtSdd8/knL0kZaL+6LbNCpzzR/UTZoAqsYtJuQtI8cWAN3tID0MnfM4cNjBwNmV/BBVk8=,iv:56z1d2E/WQ0UP0wyHvaI5YKZoY+90f5AyyxVUhHKEWs=,tag:jiNKYovn37rfG2YHoB4J0g==,type:str]", "radicale_git_email": "ENC[AES256_GCM,data:xBjo3aIPEH3WIg8qBfMrQ1VXeEkUZ5Ynl0dEWeYGirqL/Y9QOA==,iv:bMi2QCvCnhfQT7+jTXb9PzVPDVr9DPiaEVmVMTRVGZI=,tag:V7Bmp/KGKpaH1ldHwF3/jA==,type:str]", "miniflux_admin_password": "ENC[AES256_GCM,data:aXh6cBst5q7hJja5Ew8pg0ZE0c2Beo8sIwWpsuq6L1ENEAtrgfLf4lCE1MYzmmM9qXLt4ax6,iv:fgUW/eRfL7t2ttDdjxaBIGEJLt5o6Vzxv1ibSvh4XiI=,tag:h/IUuMq333LMwYEQJ5N2aQ==,type:str]", + "grafana_admin_password": "ENC[AES256_GCM,data:GOeJiU7YknnOZyBcMYwLfy1T0Ic=,iv:up11zvxz5TuO8i7A7MZ1A6iZMTicbhKKxWRUFrXqy8Y=,tag:Qf5u2mH/S9CM0jLfnUXLKQ==,type:str]", + "grafana_secret_key": "ENC[AES256_GCM,data:Rh3Ecdv51eunkxc+uIdDMMHBpuk=,iv:IzYHWNYZbA6p/X+EhZBfZDlfi7upZV72B6yZVodaZdU=,tag:+c3yB2P8t1JB+VD3sweR1Q==,type:str]", "sops": { "kms": null, "gcp_kms": null, @@ -26,8 +28,8 @@ "enc": "-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBhL1FxdG1HM2VYdFNjMzJT\nOUZFNzFIMERNOWFNNWpGM1dVWFNQU3ZCYWhnCkdYZWdsRWpncDAzYTBaRzE5SFNq\nNFJhT3lXTElXVlJBaStaczhoYnorNWMKLS0tIDF1dlg0S1hnSkxjc01XUUVFcnd6\nSXJyL1BGb2JiVUpNK0FoNEo4cGRBL0EKdR+ZKb8hbP0wmjrzc0e3aIG5rGcyHm8g\njPfEtQx1Vt7rLSmWLNbw8tTx/5G3KFR1Bxa2t7pzEocJMDRW1g/gJA==\n-----END AGE ENCRYPTED FILE-----\n" } ], - "lastmodified": "2023-07-20T11:56:18Z", - "mac": "ENC[AES256_GCM,data:UOeXXZTGWiEVojn7ivUzPk7Et9JGbHxdvs4DH9aH9YV003PEGfDxpKMKZpSZeOlrrDATHr6pUzRFSci8ucMCACMaRIr7lUtgPxC+HZ3bfOxger2aWLr5HlXwlCI+GB8EEX5I+2eNWVmFOtRY9x63FjvHvG/uY6g+cyLtEAAonNU=,iv:HNv8k19z9BeGvpPWuFHYW4tZ9aOm1vIcxx3td1vpT4c=,tag:dPNPmU19giqy0S+Cgk2vdQ==,type:str]", + "lastmodified": "2023-07-21T20:59:51Z", + "mac": "ENC[AES256_GCM,data:/y/3XKfdtgxZWVFqOVDyR6wHCwCWg6YS/VV5Bne8blt8jLlVQSnzXY/nDhvy6I9MBxmPEzKlc0aWEW6WMtfHMTJ+R9Rz748zX1RFv4yoH3bnkfql0vzIR4swRivdrUEwtjvnfHF4KtvxxD86ZgDGQSOv3+XEMUtKsAx/3zlt8ZY=,iv:7YdGMWafBWGUl2UCDAp85Gy831tXKP7BOznzO9muVPw=,tag:1af74Cw14vRqsZ3DMH594Q==,type:str]", "pgp": null, "unencrypted_suffix": "_unencrypted", "version": "3.7.3" diff --git a/PulumiWebServer/PulumiWebServer.fsproj b/PulumiWebServer/PulumiWebServer.fsproj index f4865cc..7605faf 100644 --- a/PulumiWebServer/PulumiWebServer.fsproj +++ b/PulumiWebServer/PulumiWebServer.fsproj @@ -47,6 +47,7 @@ +