diff --git a/modules/services/prometheus/default.nix b/modules/services/prometheus/default.nix index bbc41e0..b6ef187 100644 --- a/modules/services/prometheus/default.nix +++ b/modules/services/prometheus/default.nix @@ -111,6 +111,11 @@ in options.path = pkgs.grafana-dashboards.prometheus; disableDeletion = true; } + { + name = "Systemd"; + options.path = pkgs.grafana-dashboards.node-systemd; + disableDeletion = true; + } ]; }; diff --git a/pkgs/grafana-dashboards/default.nix b/pkgs/grafana-dashboards/default.nix index b1a394b..a039486 100644 --- a/pkgs/grafana-dashboards/default.nix +++ b/pkgs/grafana-dashboards/default.nix @@ -33,6 +33,14 @@ in version = "31"; hash = "sha256-QsRHsnayYRRGc+2MfhaKGYpNdH02PesnR5b50MDzHIg="; }; + node-systemd = (buildGrafanaDashboard { + id = 1617; + pname = "node-systemd"; + version = "1"; + hash = "sha256-MEWU5rIqlbaGu3elqdSoMZfbk67WDnH0VWuC8FqZ8v8="; + }).overrideAttrs (self: super: { + src = ./node-systemd.json; # sadly only imported dashboards work + }); nginx = buildGrafanaDashboard { id = 12708; diff --git a/pkgs/grafana-dashboards/node-systemd.json b/pkgs/grafana-dashboards/node-systemd.json new file mode 100644 index 0000000..c1469ba --- /dev/null +++ b/pkgs/grafana-dashboards/node-systemd.json @@ -0,0 +1,695 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": { + "type": "grafana", + "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": "Show stats from node_exporter systemd collector.", + "editable": true, + "fiscalYearStartMonth": 0, + "gnetId": 1617, + "graphTooltip": 0, + "id": 44, + "links": [], + "liveNow": false, + "panels": [ + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 8, + "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "refId": "A" + } + ], + "title": "Global Systemd State Count", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "decimals": 0, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 11, + "w": 24, + "x": 0, + "y": 1 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "alignAsTable": true, + "avg": true, + "current": true, + "max": true, + "min": true, + "rightSide": true, + "show": true, + "total": false, + "values": true + }, + "lines": false, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.4.7", + "pointradius": 3, + "points": true, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "expr": "sum(node_systemd_unit_state) by (state)", + "interval": "1m", + "intervalFactor": 2, + "legendFormat": "{{ state }}", + "metric": "node_systemd_unit_state", + "refId": "A", + "step": 120 + } + ], + "thresholds": [], + "timeFrom": "24h", + "timeRegions": [], + "title": "Unit State Count", + "tooltip": { + "shared": true, + "sort": 1, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "logBase": 1, + "show": true + }, + { + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + }, + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 12 + }, + "id": 9, + "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "refId": "A" + } + ], + "title": "Dashboard Row", + "type": "row" + }, + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": 5 + }, + { + "color": "rgba(245, 54, 54, 0.9)", + "value": 13 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 0, + "y": 13 + }, + "id": 3, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "background", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.4.7", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "expr": "sum(node_systemd_unit_state{instance=~\"^$Node$\", state=\"activating\"})", + "interval": "", + "intervalFactor": 2, + "legendFormat": "", + "metric": "node_systemd_unit_state", + "refId": "A", + "step": 600 + } + ], + "title": "Activating", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "rgb(31, 120, 193)", + "mode": "fixed" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 6, + "y": 13 + }, + "id": 4, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.4.7", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "expr": "sum(node_systemd_unit_state{instance=~\"^$Node$\", state=\"active\"})", + "interval": "", + "intervalFactor": 2, + "legendFormat": "", + "metric": "node_systemd_unit_state", + "refId": "A", + "step": 600 + } + ], + "title": "Active", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "rgba(50, 172, 45, 0.97)", + "value": null + }, + { + "color": "rgba(237, 129, 40, 0.89)", + "value": null + }, + { + "color": "rgba(245, 54, 54, 0.9)" + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 12, + "y": 13 + }, + "id": 5, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "background", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.4.7", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "expr": "sum(node_systemd_unit_state{instance=~\"^$Node$\", state=\"failed\"})", + "interval": "", + "intervalFactor": 2, + "legendFormat": "", + "metric": "node_systemd_unit_state", + "refId": "A", + "step": 600 + } + ], + "title": "Failed", + "type": "stat" + }, + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "fieldConfig": { + "defaults": { + "color": { + "fixedColor": "rgb(31, 120, 193)", + "mode": "fixed" + }, + "mappings": [ + { + "options": { + "match": "null", + "result": { + "text": "N/A" + } + }, + "type": "special" + } + ], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + }, + "unit": "none" + }, + "overrides": [] + }, + "gridPos": { + "h": 3, + "w": 6, + "x": 18, + "y": 13 + }, + "id": 6, + "links": [], + "maxDataPoints": 100, + "options": { + "colorMode": "none", + "graphMode": "area", + "justifyMode": "auto", + "orientation": "horizontal", + "reduceOptions": { + "calcs": [ + "mean" + ], + "fields": "", + "values": false + }, + "textMode": "auto" + }, + "pluginVersion": "9.4.7", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "expr": "sum(node_systemd_unit_state{instance=~\"^$Node$\", state=\"inactive\"})", + "interval": "", + "intervalFactor": 2, + "legendFormat": "", + "metric": "node_systemd_unit_state", + "refId": "A", + "step": 600 + } + ], + "title": "Inactive", + "type": "stat" + }, + { + "collapsed": false, + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 16 + }, + "id": 10, + "panels": [], + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "refId": "A" + } + ], + "title": "Dashboard Row", + "type": "row" + }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 17 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "alignAsTable": true, + "avg": false, + "current": false, + "max": false, + "min": false, + "rightSide": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pluginVersion": "9.4.7", + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "expr": "sum(node_systemd_unit_state{instance=~\"^.*$\",state=\"failed\"}) by (name, state) > 0", + "intervalFactor": 2, + "metric": "node_systemd_unit_state", + "refId": "A", + "step": 20 + } + ], + "thresholds": [], + "timeRegions": [], + "title": "Failed Services", + "tooltip": { + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "mode": "time", + "show": true, + "values": [] + }, + "yaxes": [ + { + "format": "short", + "logBase": 1, + "show": true + }, + { + "format": "short", + "logBase": 1, + "show": true + } + ], + "yaxis": { + "align": false + } + } + ], + "refresh": "", + "revision": 1, + "schemaVersion": 38, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "current": { + "selected": false, + "text": "newton", + "value": "newton" + }, + "datasource": { + "type": "prometheus", + "uid": "KNkR71YVk" + }, + "definition": "", + "hide": 0, + "includeAll": false, + "multi": false, + "name": "Node", + "options": [], + "query": { + "query": "label_values(node_systemd_unit_state, instance)", + "refId": "Prometheus-Node-Variable-Query" + }, + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "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": "browser", + "title": "Systemd Service Dashboard", + "uid": "T1ZsWHP4z", + "version": 1, + "weekStart": "" +}