version: '3.9'
services:
  postgresql-exporter:
    image: prometheuscommunity/postgres-exporter:v0.15.0
    environment:
      - DATA_SOURCE_NAME=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql_postgresql_primary:5432/postgres?sslmode=disable
    networks:
      - monitoring-network
    ports:
      - "9187:9187"
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9187/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s
    deploy:
      resources:
        limits:
          memory: 256M
          cpus: '0.25'
        reservations:
          memory: 128M
          cpus: '0.1'
      placement:
        constraints:
          - node.role == manager

networks:
  monitoring-network:
    external: true
