From 22e1764d84835a4ee5e2983444a63d240998348e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B0=D0=BC=D0=BE=D1=85=D0=B2=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9=20=D0=A0=D0=B5?= =?UTF-8?q?=D0=BC=D0=BE=D0=B2=D0=B8=D1=87?= Date: Fri, 2 Oct 2026 14:16:47 +0300 Subject: [PATCH] feat: Add pinned telemetry stack and Grafana provisioning (U1) Wire OTLP metrics, logs, and traces to Prometheus, Loki, and Tempo with bounded Collector queues. Provision Grafana sources and a dashboard based on the stores' and Collector's documented metrics. Runtime integration awaits the application Compose stack; static syntax and wiring checks pass. --- compose.telemetry.yaml | 59 +++++++++++++++ infra/grafana/dashboards/telemetry.json | 46 ++++++++++++ .../provisioning/dashboards/dashboards.yaml | 7 ++ .../provisioning/datasources/datasources.yaml | 18 +++++ infra/loki/config.yaml | 32 +++++++++ infra/otel/collector.yaml | 72 +++++++++++++++++++ infra/prometheus/prometheus.yml | 16 +++++ infra/tempo/config.yaml | 17 +++++ 8 files changed, 267 insertions(+) create mode 100644 compose.telemetry.yaml create mode 100644 infra/grafana/dashboards/telemetry.json create mode 100644 infra/grafana/provisioning/dashboards/dashboards.yaml create mode 100644 infra/grafana/provisioning/datasources/datasources.yaml create mode 100644 infra/loki/config.yaml create mode 100644 infra/otel/collector.yaml create mode 100644 infra/prometheus/prometheus.yml create mode 100644 infra/tempo/config.yaml diff --git a/compose.telemetry.yaml b/compose.telemetry.yaml new file mode 100644 index 0000000..8201791 --- /dev/null +++ b/compose.telemetry.yaml @@ -0,0 +1,59 @@ +# Add with: docker compose -f compose.yaml -f compose.telemetry.yaml up -d +services: + otel-collector: + image: otel/opentelemetry-collector-contrib:0.128.0 + command: ["--config=/etc/otelcol-contrib/collector.yaml"] + mem_limit: 384m + volumes: + - ./infra/otel/collector.yaml:/etc/otelcol-contrib/collector.yaml:ro + depends_on: + - prometheus + - loki + - tempo + + prometheus: + image: prom/prometheus:v3.5.0 + command: + - --config.file=/etc/prometheus/prometheus.yml + - --storage.tsdb.path=/prometheus + - --storage.tsdb.retention.time=7d + - --web.enable-remote-write-receiver + volumes: + - ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro + - prometheus_data:/prometheus + + loki: + image: grafana/loki:3.5.0 + command: ["-config.file=/etc/loki/config.yaml"] + volumes: + - ./infra/loki/config.yaml:/etc/loki/config.yaml:ro + - loki_data:/loki + + tempo: + image: grafana/tempo:2.9.5 + command: ["-config.file=/etc/tempo/config.yaml"] + volumes: + - ./infra/tempo/config.yaml:/etc/tempo/config.yaml:ro + - tempo_data:/var/tempo + + grafana: + image: grafana/grafana:12.0.2 + ports: + - "127.0.0.1:${GRAFANA_PORT:-3000}:3000" + environment: + GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:?Set GRAFANA_ADMIN_PASSWORD in local .env} + volumes: + - grafana_data:/var/lib/grafana + - ./infra/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources:ro + - ./infra/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards:ro + - ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro + depends_on: + - prometheus + - loki + - tempo + +volumes: + prometheus_data: + loki_data: + tempo_data: + grafana_data: diff --git a/infra/grafana/dashboards/telemetry.json b/infra/grafana/dashboards/telemetry.json new file mode 100644 index 0000000..4811866 --- /dev/null +++ b/infra/grafana/dashboards/telemetry.json @@ -0,0 +1,46 @@ +{ + "uid": "lab6-telemetry", + "title": "Lab 6 ยท Telemetry stack", + "tags": ["lab6"], + "timezone": "browser", + "schemaVersion": 40, + "version": 1, + "refresh": "10s", + "time": { "from": "now-1h", "to": "now" }, + "panels": [ + { + "id": 1, + "type": "timeseries", + "title": "Telemetry stores and collector reachable", + "description": "Prometheus self-scrape and internal /metrics endpoints. API and worker panels follow their actual exported metric names.", + "datasource": { "type": "prometheus", "uid": "prometheus" }, + "targets": [ + { + "refId": "A", + "expr": "up{job=~\"prometheus|otel-collector|loki|tempo\"}", + "legendFormat": "{{job}}" + } + ], + "fieldConfig": { "defaults": { "min": 0, "max": 1 }, "overrides": [] }, + "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, + "gridPos": { "h": 8, "w": 24, "x": 0, "y": 0 } + }, + { + "id": 2, + "type": "timeseries", + "title": "Collector exporter queue size", + "description": "Bounded exporter queues, sourced from the Collector's own Prometheus endpoint.", + "datasource": { "type": "prometheus", "uid": "prometheus" }, + "targets": [ + { + "refId": "A", + "expr": "otelcol_exporter_queue_size{job=\"otel-collector\"}", + "legendFormat": "{{exporter}}" + } + ], + "fieldConfig": { "defaults": { "min": 0 }, "overrides": [] }, + "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, + "gridPos": { "h": 8, "w": 24, "x": 0, "y": 8 } + } + ] +} diff --git a/infra/grafana/provisioning/dashboards/dashboards.yaml b/infra/grafana/provisioning/dashboards/dashboards.yaml new file mode 100644 index 0000000..e172240 --- /dev/null +++ b/infra/grafana/provisioning/dashboards/dashboards.yaml @@ -0,0 +1,7 @@ +apiVersion: 1 +providers: + - name: Lab 6 + type: file + allowUiUpdates: false + options: + path: /var/lib/grafana/dashboards diff --git a/infra/grafana/provisioning/datasources/datasources.yaml b/infra/grafana/provisioning/datasources/datasources.yaml new file mode 100644 index 0000000..f03287e --- /dev/null +++ b/infra/grafana/provisioning/datasources/datasources.yaml @@ -0,0 +1,18 @@ +apiVersion: 1 +datasources: + - name: Prometheus + uid: prometheus + type: prometheus + access: proxy + url: http://prometheus:9090 + isDefault: true + - name: Loki + uid: loki + type: loki + access: proxy + url: http://loki:3100 + - name: Tempo + uid: tempo + type: tempo + access: proxy + url: http://tempo:3200 diff --git a/infra/loki/config.yaml b/infra/loki/config.yaml new file mode 100644 index 0000000..508633a --- /dev/null +++ b/infra/loki/config.yaml @@ -0,0 +1,32 @@ +auth_enabled: false + +server: + http_listen_port: 3100 + +common: + path_prefix: /loki + storage: + filesystem: + chunks_directory: /loki/chunks + rules_directory: /loki/rules + replication_factor: 1 + ring: + instance_addr: 127.0.0.1 + kvstore: + store: inmemory + +schema_config: + configs: + - from: "2024-01-01" + store: tsdb + object_store: filesystem + schema: v13 + index: + prefix: index_ + period: 24h + +limits_config: + allow_structured_metadata: true + +analytics: + reporting_enabled: false diff --git a/infra/otel/collector.yaml b/infra/otel/collector.yaml new file mode 100644 index 0000000..013d283 --- /dev/null +++ b/infra/otel/collector.yaml @@ -0,0 +1,72 @@ +receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + http: + endpoint: 0.0.0.0:4318 + +processors: + memory_limiter: + check_interval: 1s + limit_mib: 256 + spike_limit_mib: 64 + batch: + timeout: 2s + send_batch_size: 512 + +exporters: + prometheusremotewrite: + endpoint: http://prometheus:9090/api/v1/write + tls: + insecure: true + remote_write_queue: + enabled: true + queue_size: 1000 + num_consumers: 1 + retry_on_failure: + enabled: true + max_elapsed_time: 30s + otlphttp/loki: + endpoint: http://loki:3100/otlp + sending_queue: + enabled: true + queue_size: 64 + retry_on_failure: + enabled: true + max_elapsed_time: 30s + otlp/tempo: + endpoint: tempo:4317 + tls: + insecure: true + sending_queue: + enabled: true + queue_size: 64 + retry_on_failure: + enabled: true + max_elapsed_time: 30s + +service: + telemetry: + metrics: + readers: + - pull: + exporter: + prometheus: + host: 0.0.0.0 + port: 8888 + without_type_suffix: true + without_units: true + pipelines: + metrics: + receivers: [otlp] + processors: [memory_limiter, batch] + exporters: [prometheusremotewrite] + logs: + receivers: [otlp] + processors: [memory_limiter, batch] + exporters: [otlphttp/loki] + traces: + receivers: [otlp] + processors: [memory_limiter, batch] + exporters: [otlp/tempo] diff --git a/infra/prometheus/prometheus.yml b/infra/prometheus/prometheus.yml new file mode 100644 index 0000000..b56d200 --- /dev/null +++ b/infra/prometheus/prometheus.yml @@ -0,0 +1,16 @@ +global: + scrape_interval: 15s + +scrape_configs: + - job_name: prometheus + static_configs: + - targets: ["localhost:9090"] + - job_name: otel-collector + static_configs: + - targets: ["otel-collector:8888"] + - job_name: loki + static_configs: + - targets: ["loki:3100"] + - job_name: tempo + static_configs: + - targets: ["tempo:3200"] diff --git a/infra/tempo/config.yaml b/infra/tempo/config.yaml new file mode 100644 index 0000000..9f813a2 --- /dev/null +++ b/infra/tempo/config.yaml @@ -0,0 +1,17 @@ +server: + http_listen_port: 3200 + +distributor: + receivers: + otlp: + protocols: + grpc: + endpoint: 0.0.0.0:4317 + +storage: + trace: + backend: local + wal: + path: /var/tempo/wal + local: + path: /var/tempo/blocks