From 6c5f7c08b54501c53f2211a0ec4dc3c152c29051 Mon Sep 17 00:00:00 2001 From: Lars Hampe Date: Tue, 12 Nov 2024 21:56:28 +0100 Subject: [PATCH] ci: extend grafana logs dashboard --- ci/development/docker-compose.yaml | 42 +++-- ci/development/grafana/dashboard.yaml | 12 ++ .../grafana/dashboards/api-logs.json | 175 +++++++++++++++++- .../grafana/dashboards/dashboard.yaml | 12 ++ ci/development/grafana/datasources/loki.yaml | 11 ++ package.json | 1 + 6 files changed, 232 insertions(+), 21 deletions(-) create mode 100644 ci/development/grafana/dashboard.yaml create mode 100644 ci/development/grafana/dashboards/dashboard.yaml create mode 100644 ci/development/grafana/datasources/loki.yaml diff --git a/ci/development/docker-compose.yaml b/ci/development/docker-compose.yaml index 0a16b1b..7fa0d8b 100644 --- a/ci/development/docker-compose.yaml +++ b/ci/development/docker-compose.yaml @@ -30,24 +30,28 @@ services: - GF_PATHS_PROVISIONING=/etc/grafana/provisioning - GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin - entrypoint: - - sh - - -euc - - | - mkdir -p /etc/grafana/provisioning/datasources - cat < /etc/grafana/provisioning/datasources/ds.yaml - apiVersion: 1 - datasources: - - name: Loki - type: loki - access: proxy - orgId: 1 - url: http://loki:3100 - basicAuth: false - isDefault: true - version: 1 - editable: false - EOF - /run.sh + volumes: + - ./grafana/dashboard.yaml:/etc/grafana/provisioning/dashboards/main.yaml + - ./grafana/dashboards:/var/lib/grafana/dashboards + - ./grafana/datasources:/etc/grafana/provisioning/datasources + # entrypoint: + # - sh + # - -euc + # - | + # mkdir -p /etc/grafana/provisioning/datasources + # cat < /etc/grafana/provisioning/datasources/ds.yaml + # apiVersion: 1 + # datasources: + # - name: Loki + # type: loki + # access: proxy + # orgId: 1 + # url: http://loki:3100 + # basicAuth: false + # isDefault: true + # version: 1 + # editable: false + # EOF + # /run.sh ports: - "9000:3000" \ No newline at end of file diff --git a/ci/development/grafana/dashboard.yaml b/ci/development/grafana/dashboard.yaml new file mode 100644 index 0000000..57d3797 --- /dev/null +++ b/ci/development/grafana/dashboard.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: + - name: "Dashboard provider" + orgId: 1 + type: file + disableDeletion: false + updateIntervalSeconds: 10 + allowUiUpdates: false + options: + path: /var/lib/grafana/dashboards + foldersFromFilesStructure: true \ No newline at end of file diff --git a/ci/development/grafana/dashboards/api-logs.json b/ci/development/grafana/dashboards/api-logs.json index 2e89de6..7eaa962 100644 --- a/ci/development/grafana/dashboards/api-logs.json +++ b/ci/development/grafana/dashboards/api-logs.json @@ -205,6 +205,177 @@ "title": "400 - 499", "type": "stat" }, + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "blue", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 0, + "y": 9 + }, + "id": 7, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["sum"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.3.0", + "targets": [ + { + "editorMode": "builder", + "expr": "count(rate({service=\"api\"} | json | level = `info` [$__auto]))", + "queryType": "range", + "refId": "A" + } + ], + "title": "Info", + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "yellow", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 4, + "y": 9 + }, + "id": 8, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["sum"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.3.0", + "targets": [ + { + "editorMode": "builder", + "expr": "count(rate({service=\"api\"} | json | level = `warn` [$__auto]))", + "queryType": "range", + "refId": "A" + } + ], + "title": "Warning", + "type": "stat" + }, + { + "datasource": { + "type": "loki", + "uid": "P8E80F9AEF21F6940" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "red", + "value": null + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 4, + "x": 8, + "y": 9 + }, + "id": 9, + "options": { + "colorMode": "value", + "graphMode": "none", + "justifyMode": "auto", + "orientation": "auto", + "percentChangeColorMode": "standard", + "reduceOptions": { + "calcs": ["sum"], + "fields": "", + "values": false + }, + "showPercentChange": false, + "textMode": "auto", + "wideLayout": true + }, + "pluginVersion": "11.3.0", + "targets": [ + { + "editorMode": "builder", + "expr": "count(rate({service=\"api\"} | json | level = `error` [$__auto]))", + "queryType": "range", + "refId": "A" + } + ], + "title": "Error", + "type": "stat" + }, { "datasource": { "type": "loki", @@ -218,7 +389,7 @@ "h": 17, "w": 24, "x": 0, - "y": 9 + "y": 17 }, "id": 5, "options": { @@ -258,6 +429,6 @@ "timezone": "browser", "title": "Logging", "uid": "be3r0x46iwlq8f", - "version": 12, + "version": 1, "weekStart": "monday" } diff --git a/ci/development/grafana/dashboards/dashboard.yaml b/ci/development/grafana/dashboards/dashboard.yaml new file mode 100644 index 0000000..57d3797 --- /dev/null +++ b/ci/development/grafana/dashboards/dashboard.yaml @@ -0,0 +1,12 @@ +apiVersion: 1 + +providers: + - name: "Dashboard provider" + orgId: 1 + type: file + disableDeletion: false + updateIntervalSeconds: 10 + allowUiUpdates: false + options: + path: /var/lib/grafana/dashboards + foldersFromFilesStructure: true \ No newline at end of file diff --git a/ci/development/grafana/datasources/loki.yaml b/ci/development/grafana/datasources/loki.yaml new file mode 100644 index 0000000..e88b0c5 --- /dev/null +++ b/ci/development/grafana/datasources/loki.yaml @@ -0,0 +1,11 @@ +apiVersion: 1 +datasources: + - name: Loki + type: loki + access: proxy + orgId: 1 + url: http://loki:3100 + basicAuth: false + isDefault: true + version: 1 + editable: false \ No newline at end of file diff --git a/package.json b/package.json index 4ecab31..95b6d72 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "dev": "bun --filter '*' dev", "dev:docker:up": "docker compose -f ci/development/docker-compose.yaml up -d", "dev:docker:down": "docker compose -f ci/development/docker-compose.yaml down", + "dev:docker:stop": "docker compose -f ci/development/docker-compose.yaml stop", "build": "bun --filter '*' build", "db:generate": "bun --filter '@boring.tools/database' db:generate", "db:migrate": "bun --filter '@boring.tools/database' db:migrate",