diff --git a/modules/services/grafana.nix b/modules/services/grafana.nix index 1df0e2f..ad27c92 100644 --- a/modules/services/grafana.nix +++ b/modules/services/grafana.nix @@ -2,6 +2,7 @@ let useHttps = config.services.step-ca.enable; fqdn = "grafana.home.arpa"; + base = "/mnt/250ssd"; in { age.secrets.grafana-contact-points = { @@ -12,11 +13,16 @@ in services.grafana = { enable = true; + dataDir = "${base}/grafana"; settings.server = { domain = fqdn; http_port = 2342; http_addr = "127.0.0.1"; }; + settings.log = { + mode = "console"; + level = "warn"; + }; provision.alerting.contactPoints.path = config.age.secrets.grafana-contact-points.path; provision.alerting.policies.path = ./grafana/notification-policies.yml; @@ -30,6 +36,11 @@ in type = "prometheus"; isDefault = true; } + { + name = "loki"; + url = "http://localhost:3100"; + type = "loki"; + } ]; }; provision.dashboards.settings.providers = [{ @@ -62,6 +73,7 @@ in node = { enable = true; enabledCollectors = [ "systemd" ]; + disabledCollectors = [ "arp" ]; port = 9001; }; }; @@ -91,7 +103,7 @@ in # Logs services.loki = { enable = true; - dataDir = "/mnt/250ssd/loki"; + dataDir = "${base}/loki"; configFile = ./grafana/loki.yml; }; diff --git a/modules/services/grafana/dashboards/docker.json b/modules/services/grafana/dashboards/docker.json new file mode 100644 index 0000000..adcf8ec --- /dev/null +++ b/modules/services/grafana/dashboards/docker.json @@ -0,0 +1,235 @@ +{ + "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": 4, + "links": [], + "panels": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFE396EC0B189D67" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 14, + "w": 8, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "10.4.1", + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFE396EC0B189D67" + }, + "disableTextWrap": false, + "editorMode": "builder", + "expr": "container_last_seen{name=~\".+\"}", + "fullMetaSearch": false, + "includeNullMetadata": true, + "instant": false, + "legendFormat": "__auto", + "range": true, + "refId": "A", + "useBackend": false + } + ], + "title": "Panel Title", + "transformations": [ + { + "id": "timeSeriesTable", + "options": { + "A": { + "timeField": "Time" + } + } + }, + { + "id": "filterFieldsByName", + "options": { + "byVariable": false, + "include": { + "names": [ + "image", + "name", + "Trend #A" + ] + } + } + } + ], + "type": "table" + }, + { + "datasource": { + "type": "prometheus", + "uid": "PBFE396EC0B189D67" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "axisBorderShow": false, + "axisCenteredZero": false, + "axisColorMode": "text", + "axisLabel": "", + "axisPlacement": "auto", + "barAlignment": 0, + "drawStyle": "line", + "fillOpacity": 0, + "gradientMode": "none", + "hideFrom": { + "legend": false, + "tooltip": false, + "viz": false + }, + "insertNulls": 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": 10, + "w": 12, + "x": 8, + "y": 0 + }, + "id": 2, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom", + "showLegend": true + }, + "tooltip": { + "mode": "single", + "sort": "none" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "PBFE396EC0B189D67" + }, + "editorMode": "code", + "exemplar": false, + "expr": "container_last_seen{name=~\".+\"}", + "format": "time_series", + "instant": false, + "legendFormat": "{{name}}", + "range": true, + "refId": "A" + } + ], + "title": "Panel Title", + "type": "timeseries" + } + ], + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Docker", + "uid": "cdijlo7pmmby8c", + "version": 4, + "weekStart": "" +} diff --git a/modules/services/grafana/dashboards/logs.json b/modules/services/grafana/dashboards/logs.json new file mode 100644 index 0000000..48b1c6e --- /dev/null +++ b/modules/services/grafana/dashboards/logs.json @@ -0,0 +1,75 @@ +{ + "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, + "links": [], + "panels": [ + { + "datasource": { + "type": "loki", + "uid": "P982945308D3682D1" + }, + "gridPos": { + "h": 30, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 1, + "options": { + "dedupStrategy": "none", + "enableLogDetails": true, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "P982945308D3682D1" + }, + "expr": "{job=\"systemd-journal\"}", + "queryType": "range", + "refId": "A" + } + ], + "title": "New Panel", + "type": "logs" + } + ], + "schemaVersion": 39, + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "browser", + "title": "Logs", + "uid": "bdiq4odego6psd", + "version": 1, + "weekStart": "" +} diff --git a/modules/services/grafana/loki.yml b/modules/services/grafana/loki.yml index ceabe5c..cf1d39e 100644 --- a/modules/services/grafana/loki.yml +++ b/modules/services/grafana/loki.yml @@ -6,6 +6,7 @@ auth_enabled: false server: http_listen_port: 3100 + log_level: "warn" common: ring: