forked from mtusi2026/mtusi2026lab6
ЛР6: наблюдаемость, сквозные traces и исследование sampling
This commit is contained in:
+298
@@ -0,0 +1,298 @@
|
||||
name: mtusi-lab6
|
||||
x-application: &application
|
||||
image: mtusi-messenger:lab6
|
||||
networks: [backend]
|
||||
environment: &environment
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
CACHE_URL_FILE: /run/secrets/cache_url
|
||||
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
|
||||
HTTP_WORKERS: ${HTTP_WORKERS:-16}
|
||||
DB_POOL_MAX: ${DB_POOL_MAX:-8}
|
||||
DB_ACCESS_MODE: ${DB_ACCESS_MODE:-optimized}
|
||||
LOG_LEVEL: WARNING
|
||||
TELEMETRY_ENABLED: ${TELEMETRY_ENABLED:-1}
|
||||
TRACE_SAMPLE_RATIO: ${TRACE_SAMPLE_RATIO:-0.25}
|
||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://otel-collector:4318
|
||||
MAX_PENDING_JOBS: ${MAX_PENDING_JOBS:-100}
|
||||
JOB_MAX_ATTEMPTS: ${JOB_MAX_ATTEMPTS:-5}
|
||||
S3_ENDPOINT: http://s3:8333
|
||||
S3_BUCKET: messenger-attachments
|
||||
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_api_key
|
||||
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_api_secret
|
||||
secrets: [database_url, cache_url, s3_api_key, s3_api_secret]
|
||||
tmpfs: ["/tmp:size=128m,mode=1777"]
|
||||
mem_limit: ${API_MEMORY:-512m}
|
||||
cpus: ${API_CPUS:-1}
|
||||
stop_grace_period: 10s
|
||||
services:
|
||||
migrate:
|
||||
<<: *application
|
||||
command: [python, src/migrate.py]
|
||||
healthcheck:
|
||||
disable: true
|
||||
deploy:
|
||||
replicas: 1
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
api:
|
||||
<<: *application
|
||||
build: .
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
depends_on:
|
||||
otel-collector:
|
||||
condition: service_started
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
redis:
|
||||
condition: service_healthy
|
||||
bucket-bootstrap:
|
||||
condition: service_completed_successfully
|
||||
bucket-bootstrap:
|
||||
<<: *application
|
||||
command: [python, src/bucket_bootstrap.py]
|
||||
environment:
|
||||
<<: *environment
|
||||
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_admin_key
|
||||
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_admin_secret
|
||||
secrets: [s3_admin_key, s3_admin_secret]
|
||||
healthcheck:
|
||||
disable: true
|
||||
depends_on:
|
||||
s3:
|
||||
condition: service_healthy
|
||||
audit:
|
||||
<<: *application
|
||||
profiles: [tools]
|
||||
environment:
|
||||
<<: *environment
|
||||
BASE_URL: http://lb:8080
|
||||
BROKER_URL_FILE: /run/secrets/broker_url
|
||||
JOB_LEASE_SECONDS: 5
|
||||
secrets: [database_url, cache_url, s3_api_key, s3_api_secret, s3_admin_key, s3_admin_secret, s3_worker_key, s3_worker_secret, broker_url]
|
||||
healthcheck:
|
||||
disable: true
|
||||
deploy:
|
||||
replicas: 1
|
||||
dispatcher:
|
||||
<<: *application
|
||||
command: [python, src/pipeline.py, dispatch]
|
||||
environment:
|
||||
<<: *environment
|
||||
BROKER_URL_FILE: /run/secrets/broker_url
|
||||
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-60}
|
||||
secrets: [database_url, broker_url]
|
||||
healthcheck:
|
||||
disable: true
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
broker:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
worker:
|
||||
<<: *application
|
||||
command: [python, src/pipeline.py, work]
|
||||
environment:
|
||||
<<: *environment
|
||||
BROKER_URL_FILE: /run/secrets/broker_url
|
||||
S3_ACCESS_KEY_ID_FILE: /run/secrets/s3_worker_key
|
||||
S3_SECRET_ACCESS_KEY_FILE: /run/secrets/s3_worker_secret
|
||||
JOB_LEASE_SECONDS: ${JOB_LEASE_SECONDS:-60}
|
||||
JOB_TIMEOUT_SECONDS: ${JOB_TIMEOUT_SECONDS:-20}
|
||||
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-1}
|
||||
secrets: [database_url, broker_url, s3_worker_key, s3_worker_secret]
|
||||
mem_limit: ${WORKER_MEMORY:-768m}
|
||||
tmpfs: ["/tmp:size=128m,mode=1777"]
|
||||
cpus: 1
|
||||
deploy:
|
||||
replicas: 1
|
||||
healthcheck:
|
||||
disable: true
|
||||
depends_on:
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
bucket-bootstrap:
|
||||
condition: service_completed_successfully
|
||||
broker:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
broker:
|
||||
image: redis:7.4.1-bookworm@sha256:bb142a9c18ac18a16713c1491d779697b4e107c22a97266616099d288237ef47
|
||||
command: [redis-server, --appendonly, "yes", --appendfsync, always, --maxmemory, 96mb, --maxmemory-policy, noeviction, --save, ""]
|
||||
volumes: [broker_data:/data]
|
||||
networks: [backend]
|
||||
mem_limit: 192m
|
||||
cpus: 0.5
|
||||
healthcheck:
|
||||
test: [CMD, redis-cli, ping]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
s3-store:
|
||||
image: chrislusf/seaweedfs:4.51@sha256:f7a49e3f3972ebed5be2ed4befa4a0c68eb7bdddba6e692d42729ceb545134b8
|
||||
command: [mini, -dir=/data, -ip=s3-store, -s3=false, -admin.ui=false, -webdav=false, -master.telemetry=false, -master.volumeSizeLimitMB=128, -volume.max=16, -volume.fileSizeLimitMB=11, -volume.concurrentUploadLimitMB=64, -volume.concurrentDownloadLimitMB=64]
|
||||
networks: [storage]
|
||||
volumes: [s3_data:/data]
|
||||
mem_limit: 512m
|
||||
cpus: 1
|
||||
stop_grace_period: 20s
|
||||
healthcheck:
|
||||
test: [CMD, wget, -q, -O, /dev/null, http://127.0.0.1:8888/]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 45
|
||||
s3:
|
||||
image: chrislusf/seaweedfs:4.51@sha256:f7a49e3f3972ebed5be2ed4befa4a0c68eb7bdddba6e692d42729ceb545134b8
|
||||
command: [s3, -filer=s3-store:8888, -port=8333, -config=/run/secrets/s3_config, -iam=false, -port.iceberg=0, -port.lance=0, -concurrentFileUploadLimit=16, -concurrentUploadLimitMB=32, -readerCacheSizeMB=16]
|
||||
secrets: [s3_config]
|
||||
networks: [backend, storage]
|
||||
mem_limit: 512m
|
||||
environment:
|
||||
GOMEMLIMIT: 384MiB
|
||||
cpus: 0.5
|
||||
depends_on:
|
||||
s3-store:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, 'nc -z 127.0.0.1 8333']
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
lb:
|
||||
image: haproxy:3.0.5-alpine@sha256:43a2591a6a62a41dd22edb4452880e9c70de489fbd7c54ffb52d035cccbfe949
|
||||
ports: ["127.0.0.1:${APP_PORT:-18093}:8080"]
|
||||
volumes:
|
||||
- ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
networks: [edge, backend]
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
mem_limit: 64m
|
||||
cpus: 0.5
|
||||
stop_grace_period: 12s
|
||||
healthcheck:
|
||||
test: [CMD, wget, -q, -O, /dev/null, http://127.0.0.1:8080/health/ready]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 10
|
||||
postgres:
|
||||
image: postgres:17.2-bookworm@sha256:3267c505060a0052e5aa6e5175a7b41ab6b04da2f8c4540fc6e98a37210aa2d3
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
secrets: [postgres_password]
|
||||
volumes: [postgres_data:/var/lib/postgresql/data]
|
||||
networks: [backend]
|
||||
healthcheck:
|
||||
test: [CMD, pg_isready, -h, 127.0.0.1, -U, messenger, -d, messenger]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
mem_limit: 512m
|
||||
cpus: ${POSTGRES_CPUS:-1}
|
||||
redis:
|
||||
image: redis:7.4.1-bookworm@sha256:bb142a9c18ac18a16713c1491d779697b4e107c22a97266616099d288237ef47
|
||||
command: [redis-server, --maxmemory, 32mb, --maxmemory-policy, allkeys-lru, --save, "", --appendonly, "no"]
|
||||
networks: [backend]
|
||||
healthcheck:
|
||||
test: [CMD, redis-cli, ping]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
mem_limit: 64m
|
||||
cpus: 0.25
|
||||
otel-collector:
|
||||
image: otel/opentelemetry-collector-contrib:0.132.0@sha256:e0f565815b2b8e78eb9fdbb80f6190c921ab323aaa8ccceab3255c6d4225f4af
|
||||
command: [--config=/etc/otel/config.yaml]
|
||||
volumes: [./infra/otel-collector.yaml:/etc/otel/config.yaml:ro]
|
||||
networks: [backend, edge]
|
||||
ports: ["127.0.0.1:${COLLECTOR_PORT:-18896}:8888"]
|
||||
mem_limit: 256m
|
||||
cpus: 0.5
|
||||
environment:
|
||||
GOMEMLIMIT: 192MiB
|
||||
prometheus:
|
||||
image: prom/prometheus:v3.5.0@sha256:63805ebb8d2b3920190daf1cb14a60871b16fd38bed42b857a3182bc621f4996
|
||||
command: [--config.file=/etc/prometheus/prometheus.yaml, --storage.tsdb.path=/prometheus, --storage.tsdb.retention.time=24h, --storage.tsdb.retention.size=256MB]
|
||||
volumes: [./infra/prometheus.yaml:/etc/prometheus/prometheus.yaml:ro, ./infra/alerts.yaml:/etc/prometheus/alerts.yaml:ro, metrics_data:/prometheus]
|
||||
networks: [backend, edge]
|
||||
ports: ["127.0.0.1:${PROMETHEUS_PORT:-19096}:9090"]
|
||||
mem_limit: 256m
|
||||
cpus: 0.5
|
||||
loki:
|
||||
image: grafana/loki:3.5.3@sha256:3165cecce301ce5b9b6e3530284b080934a05cd5cafac3d3d82edcb887b45ecd
|
||||
command: [-config.file=/etc/loki/config.yaml]
|
||||
volumes: [./infra/loki.yaml:/etc/loki/config.yaml:ro, logs_data:/loki]
|
||||
networks: [backend, edge]
|
||||
ports: ["127.0.0.1:${LOKI_PORT:-13106}:3100"]
|
||||
mem_limit: 256m
|
||||
cpus: 0.5
|
||||
environment:
|
||||
GOMEMLIMIT: 192MiB
|
||||
tempo:
|
||||
image: grafana/tempo:2.8.2@sha256:0ef775495967cd5d7a6b2e146b6ea695d624803c8db8349fb8ce4164f719f9b7
|
||||
command: [-config.file=/etc/tempo/config.yaml]
|
||||
volumes: [./infra/tempo.yaml:/etc/tempo/config.yaml:ro, traces_data:/var/tempo]
|
||||
networks: [backend, edge]
|
||||
ports: ["127.0.0.1:${TEMPO_PORT:-13206}:3200"]
|
||||
mem_limit: 512m
|
||||
cpus: 0.5
|
||||
environment:
|
||||
GOMEMLIMIT: 384MiB
|
||||
grafana:
|
||||
image: grafana/grafana:12.1.1@sha256:a1701c2180249361737a99a01bc770db39381640e4d631825d38ff4535efa47d
|
||||
volumes: [./infra/grafana/provisioning:/etc/grafana/provisioning:ro, ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro, grafana_data:/var/lib/grafana]
|
||||
networks: [backend, edge]
|
||||
ports: ["127.0.0.1:${GRAFANA_PORT:-13006}:3000"]
|
||||
environment:
|
||||
GF_AUTH_ANONYMOUS_ENABLED: "true"
|
||||
GF_AUTH_ANONYMOUS_ORG_ROLE: Viewer
|
||||
GF_AUTH_DISABLE_LOGIN_FORM: "true"
|
||||
GF_AUTH_BASIC_ENABLED: "false"
|
||||
GF_USERS_ALLOW_SIGN_UP: "false"
|
||||
GF_USERS_VIEWERS_CAN_EDIT: "true"
|
||||
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
||||
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
||||
mem_limit: 256m
|
||||
cpus: 0.5
|
||||
|
||||
volumes:
|
||||
metrics_data:
|
||||
logs_data:
|
||||
traces_data:
|
||||
grafana_data:
|
||||
postgres_data:
|
||||
broker_data:
|
||||
s3_data:
|
||||
networks:
|
||||
edge:
|
||||
storage:
|
||||
internal: true
|
||||
backend:
|
||||
internal: true
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: ./secrets/postgres_password
|
||||
database_url:
|
||||
file: ./secrets/database_url
|
||||
cache_url:
|
||||
file: ./secrets/cache_url
|
||||
s3_admin_key:
|
||||
file: ./secrets/s3_admin_key
|
||||
s3_admin_secret:
|
||||
file: ./secrets/s3_admin_secret
|
||||
s3_api_key:
|
||||
file: ./secrets/s3_api_key
|
||||
s3_api_secret:
|
||||
file: ./secrets/s3_api_secret
|
||||
s3_config:
|
||||
file: ./secrets/s3_config
|
||||
broker_url:
|
||||
file: ./secrets/broker_url
|
||||
s3_worker_key:
|
||||
file: ./secrets/s3_worker_key
|
||||
s3_worker_secret:
|
||||
file: ./secrets/s3_worker_secret
|
||||
Reference in New Issue
Block a user