x-defaults: &defaults restart: unless-stopped logging: driver: json-file options: max-size: 100m max-file: "3" services: prometheus: <<: *defaults image: ${GLOBAL_REGISTRY:-}prom/prometheus:${PROMETHEUS_VERSION:-v3.5.0} ports: - "${PROMETHEUS_PORT_OVERRIDE:-9090}:9090" volumes: - prometheus_data:/prometheus # Optional: Mount custom configuration # - ./prometheus.yml:/etc/prometheus/prometheus.yml # - ./rules:/etc/prometheus/rules command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_TIME:-15d}' - '--storage.tsdb.retention.size=${PROMETHEUS_RETENTION_SIZE:-}' - '--web.enable-lifecycle' - '--web.enable-admin-api' - '--web.external-url=${PROMETHEUS_EXTERNAL_URL:-http://localhost:9090}' environment: - TZ=${TZ:-UTC} - PROMETHEUS_RETENTION_TIME=${PROMETHEUS_RETENTION_TIME:-15d} - PROMETHEUS_RETENTION_SIZE=${PROMETHEUS_RETENTION_SIZE:-} user: "65534:65534" # nobody user deploy: resources: limits: cpus: ${PROMETHEUS_CPU_LIMIT:-1.0} memory: ${PROMETHEUS_MEMORY_LIMIT:-2G} reservations: cpus: ${PROMETHEUS_CPU_RESERVATION:-0.25} memory: ${PROMETHEUS_MEMORY_RESERVATION:-512M} healthcheck: test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9090/-/healthy"] interval: 30s timeout: 10s retries: 3 start_period: 30s volumes: prometheus_data: