# RocketMQ Prometheus + Grafana 监控配置

version: '3.8'

services:
  # Prometheus 监控
  prometheus:
    image: prom/prometheus:latest
    container_name: rocketmq-prometheus
    ports:
      - "9090:9090"
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - ./prometheus-data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--storage.tsdb.retention.time=15d'
      - '--web.console.libraries=/etc/prometheus/console_libraries'
      - '--web.console.templates=/etc/prometheus/consoles'
      - '--web.enable-lifecycle'
    networks:
      - rocketmq-net

  # Grafana 可视化
  grafana:
    image: grafana/grafana:latest
    container_name: rocketmq-grafana
    ports:
      - "3000:3000"
    environment:
      - GF_SECURITY_ADMIN_USER=admin
      - GF_SECURITY_ADMIN_PASSWORD=admin123
      - GF_USERS_ALLOW_SIGN_UP=false
    volumes:
      - ./grafana-data:/var/lib/grafana
      - ./grafana/provisioning:/etc/grafana/provisioning
    depends_on:
      - prometheus
    networks:
      - rocketmq-net

  # RocketMQ Exporter (Prometheus Exporter for RocketMQ)
  rocketmq-exporter:
    image: apache/rocketmq-exporter:latest
    container_name: rocketmq-exporter
    ports:
      - "5557:5557"
    environment:
      - JAVA_OPTS=-Dserver.port=5557
      - ROCKETMQ_CONFIG_NAMESRVADDR=namesrv-1:9876;namesrv-2:9876
      - ROCKETMQ_CONFIG_ISVIPCHANNEL=false
    depends_on:
      - namesrv-1
      - namesrv-2
    networks:
      - rocketmq-net

networks:
  rocketmq-net:
    external: true
