From c50b5c9fcf4f9ec04fe0abdb025712725d7e2608 Mon Sep 17 00:00:00 2001 From: Gernot Glawe Date: Sun, 12 Feb 2023 14:16:37 +0100 Subject: [PATCH] Grafana Tools --- grafana-container/config/collector/config.yml | 33 + .../provisioning/dashboards/config.yml | 14 + .../dashboards/source/opentelemetry.json | 692 ++++++++++++++++++ .../provisioning/datasources/jaeger.yml | 22 + .../grafana/provisioning/datasources/loki.yml | 29 + .../provisioning/datasources/prometheus.yml | 22 + .../config/prometheus/config.yml | 14 + grafana-container/docker-compose.yml | 63 ++ 8 files changed, 889 insertions(+) create mode 100644 grafana-container/config/collector/config.yml create mode 100644 grafana-container/config/grafana/provisioning/dashboards/config.yml create mode 100644 grafana-container/config/grafana/provisioning/dashboards/source/opentelemetry.json create mode 100644 grafana-container/config/grafana/provisioning/datasources/jaeger.yml create mode 100644 grafana-container/config/grafana/provisioning/datasources/loki.yml create mode 100644 grafana-container/config/grafana/provisioning/datasources/prometheus.yml create mode 100644 grafana-container/config/prometheus/config.yml create mode 100644 grafana-container/docker-compose.yml diff --git a/grafana-container/config/collector/config.yml b/grafana-container/config/collector/config.yml new file mode 100644 index 0000000..989f31c --- /dev/null +++ b/grafana-container/config/collector/config.yml @@ -0,0 +1,33 @@ +receivers: + otlp: + protocols: + grpc: +exporters: + logging: + loglevel: debug + zipkin: + endpoint: http://zipkin:9411/api/v2/spans + jaeger: + endpoint: jaeger:14250 + tls: + insecure: true + prometheus: + endpoint: 0.0.0.0:8889 + resource_to_telemetry_conversion: + enabled: true + loki: + endpoint: http://loki:3100/loki/api/v1/push + labels: + resource: + service.name: "job" +service: + pipelines: + traces: + receivers: [otlp] + exporters: [logging, zipkin, jaeger] + metrics: + receivers: [otlp] + exporters: [logging, prometheus] + logs: + receivers: [otlp] + exporters: [logging, loki] diff --git a/grafana-container/config/grafana/provisioning/dashboards/config.yml b/grafana-container/config/grafana/provisioning/dashboards/config.yml new file mode 100644 index 0000000..799aa2f --- /dev/null +++ b/grafana-container/config/grafana/provisioning/dashboards/config.yml @@ -0,0 +1,14 @@ +apiVersion: 1 + +providers: + - name: "provider" + orgId: 1 + folder: "" + folderUid: "" + type: file + disableDeletion: false + updateIntervalSeconds: 10 + allowUiUpdates: false + options: + path: /etc/grafana/provisioning/dashboards/source + foldersFromFilesStructure: true diff --git a/grafana-container/config/grafana/provisioning/dashboards/source/opentelemetry.json b/grafana-container/config/grafana/provisioning/dashboards/source/opentelemetry.json new file mode 100644 index 0000000..7c75643 --- /dev/null +++ b/grafana-container/config/grafana/provisioning/dashboards/source/opentelemetry.json @@ -0,0 +1,692 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "target": { + "limit": 100, + "matchAny": false, + "tags": [], + "type": "dashboard" + }, + "type": "dashboard" + } + ] + }, + "editable": true, + "fiscalYearStartMonth": 0, + "graphTooltip": 0, + "links": [], + "liveNow": false, + "panels": [ + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 0 + }, + "id": 22, + "title": "Shopper", + "type": "row" + }, + { + "datasource": { + "type": "jaeger", + "uid": "jaeger_datasource" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "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": 6, + "w": 8, + "x": 0, + "y": 1 + }, + "id": 6, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "jaeger", + "uid": "jaeger_datasource" + }, + "queryType": "search", + "refId": "A", + "service": "shopper" + } + ], + "title": "Traces", + "type": "timeseries" + }, + { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "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": 6, + "w": 8, + "x": 8, + "y": 1 + }, + "id": 8, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_datasource" + }, + "exemplar": true, + "expr": "{service_name=\"shopper\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Metrics", + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "loki_datasource" + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 1 + }, + "id": 10, + "options": { + "dedupStrategy": "none", + "enableLogDetails": true, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki_datasource" + }, + "expr": "{job=\"shopper\"}", + "refId": "A" + } + ], + "title": "Logs", + "type": "logs" + }, + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 7 + }, + "id": 20, + "title": "Grocery Store", + "type": "row" + }, + { + "datasource": { + "type": "jaeger", + "uid": "jaeger_datasource" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "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": 6, + "w": 8, + "x": 0, + "y": 8 + }, + "id": 13, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "jaeger", + "uid": "jaeger_datasource" + }, + "queryType": "search", + "refId": "A", + "service": "inventory" + } + ], + "title": "Traces", + "type": "timeseries" + }, + { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "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": 6, + "w": 8, + "x": 8, + "y": 8 + }, + "id": 16, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_datasource" + }, + "exemplar": true, + "expr": "{service_name=\"grocery-store\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Metrics", + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "loki_datasource" + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 8 + }, + "id": 12, + "options": { + "dedupStrategy": "none", + "enableLogDetails": true, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki_datasource" + }, + "expr": "{job=\"grocery-store\"}", + "refId": "A" + } + ], + "title": "Logs", + "type": "logs" + }, + { + "gridPos": { + "h": 1, + "w": 24, + "x": 0, + "y": 14 + }, + "id": 18, + "title": "Legacy Inventory", + "type": "row" + }, + { + "datasource": { + "type": "jaeger", + "uid": "jaeger_datasource" + }, + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "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": 6, + "w": 8, + "x": 0, + "y": 15 + }, + "id": 14, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "jaeger", + "uid": "jaeger_datasource" + }, + "queryType": "search", + "refId": "A", + "service": "grocery-store" + } + ], + "title": "Traces", + "type": "timeseries" + }, + { + "fieldConfig": { + "defaults": { + "color": { + "mode": "palette-classic" + }, + "custom": { + "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": 6, + "w": 8, + "x": 8, + "y": 15 + }, + "id": 15, + "options": { + "legend": { + "calcs": [], + "displayMode": "list", + "placement": "bottom" + }, + "tooltip": { + "mode": "single" + } + }, + "targets": [ + { + "datasource": { + "type": "prometheus", + "uid": "prometheus_datasource" + }, + "exemplar": true, + "expr": "{service_name=\"inventory\"}", + "interval": "", + "legendFormat": "", + "refId": "A" + } + ], + "title": "Metrics", + "type": "timeseries" + }, + { + "datasource": { + "type": "loki", + "uid": "loki_datasource" + }, + "gridPos": { + "h": 6, + "w": 8, + "x": 16, + "y": 15 + }, + "id": 11, + "options": { + "dedupStrategy": "none", + "enableLogDetails": true, + "prettifyLogMessage": false, + "showCommonLabels": false, + "showLabels": false, + "showTime": false, + "sortOrder": "Descending", + "wrapLogMessage": false + }, + "targets": [ + { + "datasource": { + "type": "loki", + "uid": "loki_datasource" + }, + "expr": "{job=\"inventory\"}", + "refId": "A" + } + ], + "title": "Logs", + "type": "logs" + } + ], + "schemaVersion": 34, + "style": "light", + "tags": [], + "templating": { + "list": [] + }, + "time": { + "from": "now-5m", + "to": "now" + }, + "timepicker": {}, + "timezone": "", + "title": "OpenTelemetry", + "uid": "otel", + "version": 1, + "weekStart": "" +} \ No newline at end of file diff --git a/grafana-container/config/grafana/provisioning/datasources/jaeger.yml b/grafana-container/config/grafana/provisioning/datasources/jaeger.yml new file mode 100644 index 0000000..0054a7c --- /dev/null +++ b/grafana-container/config/grafana/provisioning/datasources/jaeger.yml @@ -0,0 +1,22 @@ +apiVersion: 1 + +deleteDatasources: + - name: Jaeger + orgId: 1 + +datasources: + - name: Jaeger + type: jaeger + access: proxy + uid: jaeger_datasource + url: http://jaeger:16686 + password: + user: + database: + basicAuth: false + basicAuthUser: + basicAuthPassword: + withCredentials: + isDefault: false + version: 1 + editable: true diff --git a/grafana-container/config/grafana/provisioning/datasources/loki.yml b/grafana-container/config/grafana/provisioning/datasources/loki.yml new file mode 100644 index 0000000..cb99940 --- /dev/null +++ b/grafana-container/config/grafana/provisioning/datasources/loki.yml @@ -0,0 +1,29 @@ +apiVersion: 1 + +deleteDatasources: + - name: Loki + orgId: 1 + +datasources: + - name: Loki + type: loki + access: proxy + uid: loki_datasource + url: http://loki:3100 + password: + user: + database: + basicAuth: false + basicAuthUser: + basicAuthPassword: + withCredentials: + isDefault: false + version: 1 + editable: true + jsonData: + maxLines: 1000 + derivedFields: + # Field with external link. + - matcherRegex: "traceID=(\\w+)" + name: TraceID + url: "http://localhost:16686/trace/$${__value.raw}" diff --git a/grafana-container/config/grafana/provisioning/datasources/prometheus.yml b/grafana-container/config/grafana/provisioning/datasources/prometheus.yml new file mode 100644 index 0000000..5971712 --- /dev/null +++ b/grafana-container/config/grafana/provisioning/datasources/prometheus.yml @@ -0,0 +1,22 @@ +apiVersion: 1 + +deleteDatasources: + - name: Prometheus + orgId: 1 + +datasources: + - name: Prometheus + type: prometheus + access: proxy + uid: prometheus_datasource + url: http://prometheus:9090 + password: + user: + database: + basicAuth: false + basicAuthUser: + basicAuthPassword: + withCredentials: + isDefault: true + version: 1 + editable: true diff --git a/grafana-container/config/prometheus/config.yml b/grafana-container/config/prometheus/config.yml new file mode 100644 index 0000000..b76ef99 --- /dev/null +++ b/grafana-container/config/prometheus/config.yml @@ -0,0 +1,14 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: "opentelemetry-collector" + scrape_interval: 5s + static_configs: + - targets: ["opentelemetry-collector:8888"] + + - job_name: "demo" + scrape_interval: 5s + static_configs: + - targets: ["opentelemetry-collector:8889"] diff --git a/grafana-container/docker-compose.yml b/grafana-container/docker-compose.yml new file mode 100644 index 0000000..2e0ecba --- /dev/null +++ b/grafana-container/docker-compose.yml @@ -0,0 +1,63 @@ +version: "3.7" +services: + opentelemetry-collector: + image: otel/opentelemetry-collector-contrib:0.42.0 + container_name: opentelemetry-collector + volumes: + - ./config/collector/config.yml/:/etc/opentelemetry-collector.yml + - /var/run/docker.sock:/var/run/docker.sock + command: + - "--config=/etc/opentelemetry-collector.yml" + networks: + - observability + ports: + - 4317:4317 + - 13133:13133 + - 8889:8889 + prometheus: + image: prom/prometheus:v2.29.2 + container_name: prometheus + volumes: + - ./config/prometheus/config.yml/:/etc/prometheus/prometheus.yml + command: + - "--config.file=/etc/prometheus/prometheus.yml" + - "--enable-feature=exemplar-storage" + ports: + - 9090:9090 + networks: + - observability + loki: + image: grafana/loki:2.3.0 + container_name: loki + ports: + - 3100:3100 + command: -config.file=/etc/loki/local-config.yaml + networks: + - observability + promtail: + image: grafana/promtail:2.3.0 + container_name: promtail + volumes: + - /var/log:/var/log + command: -config.file=/etc/promtail/config.yml + networks: + - observability + grafana: + image: grafana/grafana:8.3.3 + container_name: grafana + ports: + - 3000:3000 + volumes: + - ./config/grafana/provisioning:/etc/grafana/provisioning + networks: + - observability + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ORG_ROLE=Editor + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_AUTH_DISABLE_LOGIN_FORM=true + - GF_USERS_DEFAULT_THEME=light + +networks: + observability: +