Добавить наблюдаемость OpenTelemetry и Grafana на оценку 3
This commit is contained in:
+92
-1
@@ -1,5 +1,5 @@
|
||||
#file: noinspection ComposeUnknownValues
|
||||
# Lab5: API x2 -> durable S3 staging + PostgreSQL outbox -> publisher
|
||||
# Lab6: API x2 -> durable S3 staging + PostgreSQL outbox -> publisher
|
||||
# -> RabbitMQ -> worker -> final private S3 objects + PostgreSQL metadata.
|
||||
# Start: see REPORT.md, "Запуск из чистого clone".
|
||||
name: messenger-lab6
|
||||
@@ -53,6 +53,12 @@ x-api-env: &api-env
|
||||
WORKER_FAULT: "${WORKER_FAULT:-}"
|
||||
# API fault-injection is disabled during normal operation.
|
||||
FAULT_INJECTION: "${FAULT_INJECTION:-}"
|
||||
OTEL_SDK_DISABLED: "${OTEL_SDK_DISABLED:-false}"
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
||||
OTEL_RESOURCE_ATTRIBUTES: service.version=1.6.0,deployment.environment.name=lab
|
||||
OTEL_METRIC_EXPORT_INTERVAL: "5000"
|
||||
|
||||
services:
|
||||
db:
|
||||
@@ -252,6 +258,7 @@ services:
|
||||
command: ["python", "-m", "app.jobs"]
|
||||
environment:
|
||||
<<: *api-env
|
||||
OTEL_SERVICE_NAME: messenger-publisher
|
||||
BROKER_URL_FILE: /run/secrets/broker_url
|
||||
secrets: [database_url, cache_url, s3_access_key_id, s3_secret_access_key, broker_url]
|
||||
networks: [backend]
|
||||
@@ -271,6 +278,7 @@ services:
|
||||
command: ["python", "-m", "app.worker"]
|
||||
environment:
|
||||
<<: *api-env
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
BROKER_URL_FILE: /run/secrets/broker_url
|
||||
secrets: [database_url, cache_url, s3_access_key_id, s3_secret_access_key, broker_url]
|
||||
networks: [backend]
|
||||
@@ -307,6 +315,84 @@ services:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 128M }
|
||||
|
||||
# Telemetry is deliberately absent from API depends_on/readiness.
|
||||
# No OTLP ports on the host: application traffic stays in backend.
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:0.111.0
|
||||
command: ["--config=/etc/otelcol/collector.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/collector.yaml:/etc/otelcol/collector.yaml:ro
|
||||
networks: [backend]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 256M }
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:v2.55.0
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yaml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=7d
|
||||
- --storage.tsdb.retention.size=512MB
|
||||
volumes:
|
||||
- ./infra/prometheus:/etc/prometheus:ro
|
||||
- prometheus_data:/prometheus
|
||||
ports: ["127.0.0.1:${PROMETHEUS_PORT:-9090}:9090"]
|
||||
networks: [backend, observability]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 512M }
|
||||
|
||||
loki:
|
||||
image: grafana/loki:3.2.1
|
||||
command: ["-config.file=/etc/loki/loki.yaml"]
|
||||
volumes:
|
||||
- ./infra/loki/loki.yaml:/etc/loki/loki.yaml:ro
|
||||
- loki_data:/loki
|
||||
ports: ["127.0.0.1:${LOKI_PORT:-3100}:3100"]
|
||||
networks: [backend, observability]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 384M }
|
||||
|
||||
tempo:
|
||||
image: grafana/tempo:2.6.1
|
||||
# A new named volume needs write access for the local evaluation backend.
|
||||
user: "0:0"
|
||||
command: ["-config.file=/etc/tempo/tempo.yaml"]
|
||||
volumes:
|
||||
- ./infra/tempo/tempo.yaml:/etc/tempo/tempo.yaml:ro
|
||||
- tempo_data:/var/tempo
|
||||
ports: ["127.0.0.1:${TEMPO_PORT:-3200}:3200"]
|
||||
networks: [backend, observability]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 384M }
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:11.2.2
|
||||
environment:
|
||||
GF_AUTH_ANONYMOUS_ENABLED: "true"
|
||||
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
|
||||
GF_AUTH_DISABLE_LOGIN_FORM: "true"
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_PLUGIN_UPDATES: "false"
|
||||
volumes:
|
||||
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
||||
- grafana_data:/var/lib/grafana
|
||||
ports: ["127.0.0.1:${GRAFANA_PORT:-3000}:3000"]
|
||||
networks: [backend, observability]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 256M }
|
||||
|
||||
# Runs the public and own checks in Linux (needed on Windows: the hooks are
|
||||
# POSIX .sh scripts that call the docker CLI). Profile "tools": not started
|
||||
# by a plain "up". The Docker socket grants control over the Docker host —
|
||||
@@ -328,6 +414,7 @@ services:
|
||||
networks: [edge, backend]
|
||||
|
||||
networks:
|
||||
observability: {}
|
||||
edge: {}
|
||||
# PostgreSQL, Valkey and S3: no route outside, the LB is not attached.
|
||||
backend:
|
||||
@@ -337,6 +424,10 @@ volumes:
|
||||
postgres_data: {}
|
||||
s3_data: {}
|
||||
broker_data: {}
|
||||
prometheus_data: {}
|
||||
loki_data: {}
|
||||
tempo_data: {}
|
||||
grafana_data: {}
|
||||
|
||||
secrets:
|
||||
postgres_password:
|
||||
|
||||
Reference in New Issue
Block a user