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.
This commit is contained in:
Самохвалов Андрей Ремович
2026-10-02 14:16:47 +03:00
parent c52b2157e0
commit 22e1764d84
8 changed files with 267 additions and 0 deletions
+59
View File
@@ -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:
+46
View File
@@ -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 }
}
]
}
@@ -0,0 +1,7 @@
apiVersion: 1
providers:
- name: Lab 6
type: file
allowUiUpdates: false
options:
path: /var/lib/grafana/dashboards
@@ -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
+32
View File
@@ -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
+72
View File
@@ -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]
+16
View File
@@ -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"]
+17
View File
@@ -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