forked from mtusi2026/mtusi2026lab6
Добавить наблюдаемость и проверки отказов для ЛР 6
This commit is contained in:
+103
-8
@@ -1,3 +1,9 @@
|
||||
x-telemetry-env: &telemetry-env
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
|
||||
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
||||
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
|
||||
APP_VERSION: ${APP_VERSION:-lab6}
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.4-alpine
|
||||
@@ -41,12 +47,12 @@ services:
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
secrets: [database_url]
|
||||
volumes:
|
||||
- ./migrations:/migrations
|
||||
- ./migrations:/migrations:ro
|
||||
entrypoint: ["/bin/sh", "-ec"]
|
||||
command:
|
||||
- "-path=/migrations"
|
||||
- "-database=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}?sslmode=disable"
|
||||
- "up"
|
||||
- exec migrate -path=/migrations -database="$$(cat /run/secrets/database_url)" up
|
||||
restart: "no"
|
||||
networks: [data]
|
||||
deploy:
|
||||
@@ -69,6 +75,8 @@ services:
|
||||
s3-proxy:
|
||||
condition: service_started
|
||||
environment:
|
||||
<<: *telemetry-env
|
||||
OTEL_SERVICE_NAME: messenger-api
|
||||
PORT: ${PORT}
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS}
|
||||
@@ -80,7 +88,6 @@ services:
|
||||
CHAT_CACHE_TTL_SECONDS: 30
|
||||
DRAIN_SECONDS: 4
|
||||
GOMEMLIMIT: 200MiB
|
||||
APP_VERSION: ${APP_VERSION:-dev}
|
||||
S3_ENDPOINT: http://s3-proxy:8333
|
||||
S3_BUCKET: attachments
|
||||
S3_REGION: us-east-1
|
||||
@@ -99,7 +106,7 @@ services:
|
||||
timeout: 2s
|
||||
retries: 3
|
||||
start_period: 5s
|
||||
networks: [edge, data, s3access]
|
||||
networks: [edge, data, s3access, telemetry]
|
||||
deploy:
|
||||
replicas: 2
|
||||
resources:
|
||||
@@ -228,7 +235,9 @@ services:
|
||||
migrate: { condition: service_completed_successfully }
|
||||
s3-init: { condition: service_completed_successfully }
|
||||
broker: { condition: service_healthy }
|
||||
environment:
|
||||
environment: &pipeline-env
|
||||
<<: *telemetry-env
|
||||
OTEL_SERVICE_NAME: messenger-worker
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
BROKER_URL: redis://broker:6379/0
|
||||
S3_ENDPOINT: http://s3-proxy:8333
|
||||
@@ -243,7 +252,7 @@ services:
|
||||
IMAGE_MEMORY_MB: 384
|
||||
GOMEMLIMIT: 128MiB
|
||||
secrets: [database_url, s3_api_access_key, s3_api_secret_key]
|
||||
networks: [data, s3access]
|
||||
networks: [data, s3access, telemetry]
|
||||
stop_grace_period: 40s
|
||||
healthcheck: { disable: true }
|
||||
restart: unless-stopped
|
||||
@@ -254,10 +263,89 @@ services:
|
||||
outbox:
|
||||
<<: *pipeline
|
||||
command: ["./worker", "-mode=relay"]
|
||||
environment:
|
||||
<<: *pipeline-env
|
||||
OTEL_SERVICE_NAME: messenger-outbox
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.25", memory: 192M }
|
||||
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:0.128.0
|
||||
command: ["--config=/etc/otelcol/config.yaml"]
|
||||
environment:
|
||||
GOMEMLIMIT: 150MiB
|
||||
volumes:
|
||||
- ./infra/otel/collector.yaml:/etc/otelcol/config.yaml:ro
|
||||
networks: [telemetry]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 256M }
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:v3.5.0
|
||||
command:
|
||||
- --config.file=/etc/prometheus/prometheus.yaml
|
||||
- --storage.tsdb.path=/prometheus
|
||||
- --storage.tsdb.retention.time=7d
|
||||
- --storage.tsdb.retention.size=512MB
|
||||
volumes:
|
||||
- ./infra/otel/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro
|
||||
- ./infra/otel/alerts.yaml:/etc/prometheus/alerts.yaml:ro
|
||||
- prometheus-data:/prometheus
|
||||
networks: [telemetry]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 384M }
|
||||
|
||||
loki:
|
||||
image: grafana/loki:3.5.5
|
||||
command: ["-config.file=/etc/loki/lab.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/loki.yaml:/etc/loki/lab.yaml:ro
|
||||
- loki-data:/loki
|
||||
networks: [telemetry]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 384M }
|
||||
|
||||
tempo:
|
||||
image: grafana/tempo:2.8.2
|
||||
command: ["-config.file=/etc/tempo/lab.yaml"]
|
||||
volumes:
|
||||
- ./infra/otel/tempo.yaml:/etc/tempo/lab.yaml:ro
|
||||
- tempo-data:/var/tempo
|
||||
networks: [telemetry]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 384M }
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana:12.1.1
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
GF_AUTH_ANONYMOUS_ENABLED: "true"
|
||||
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
secrets: [grafana_admin_password]
|
||||
volumes:
|
||||
- grafana-data:/var/lib/grafana
|
||||
- ./infra/otel/grafana/provisioning:/etc/grafana/provisioning:ro
|
||||
- ./infra/otel/grafana/dashboards:/etc/grafana/dashboards:ro
|
||||
ports:
|
||||
- "127.0.0.1:${GRAFANA_PORT:-3000}:3000"
|
||||
networks: [edge, telemetry]
|
||||
restart: unless-stopped
|
||||
deploy:
|
||||
resources:
|
||||
limits: { cpus: "0.5", memory: 384M }
|
||||
|
||||
networks:
|
||||
edge:
|
||||
data:
|
||||
@@ -265,6 +353,8 @@ networks:
|
||||
internal: true
|
||||
s3access:
|
||||
internal: true
|
||||
telemetry:
|
||||
internal: true
|
||||
|
||||
secrets:
|
||||
database_url:
|
||||
@@ -276,9 +366,14 @@ secrets:
|
||||
s3_api_secret_key: { file: ./secrets/s3_api_secret_key.txt }
|
||||
s3_admin_access_key: { file: ./secrets/s3_admin_access_key.txt }
|
||||
s3_admin_secret_key: { file: ./secrets/s3_admin_secret_key.txt }
|
||||
grafana_admin_password: { file: ./secrets/grafana_admin_password.txt }
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
redis-data:
|
||||
s3-data:
|
||||
broker-data:
|
||||
prometheus-data:
|
||||
loki-data:
|
||||
tempo-data:
|
||||
grafana-data:
|
||||
|
||||
Reference in New Issue
Block a user