# ============================================
# Syslog Consumer 部署配置
# ============================================
# 使用方法: docker compose -f docker-compose-consumer.yaml up -d
# ============================================


services:
  # ============================================
  # Syslog Consumer-rule - 数据消费规则服务(平台端)
  # ============================================
  syslog-consumer:
    build:
      context: ./consumer-rule
      dockerfile: Dockerfile
    image: syslog-consumer-rule:1.0.1    
    container_name: syslog-consumer-rule
    restart: unless-stopped
    environment:
      # 环境配置
      - SPRING_PROFILES_ACTIVE=prod
      - TZ=Asia/Shanghai
      # 数据库配置
      - SPRING_DATASOURCE_URL=jdbc:postgresql://192.168.4.26:5432/ecosys
      - SPRING_DATASOURCE_USERNAME=postgres
      - SPRING_DATASOURCE_PASSWORD=caZ2TcmXNSW8L2Ap
      - SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
      # HikariCP 连接池配置
      - SPRING_DATASOURCE_HIKARI_MAXIMUM_POOL_SIZE=50
      - SPRING_DATASOURCE_HIKARI_MINIMUM_IDLE=5
      - SPRING_DATASOURCE_HIKARI_CONNECTION_TIMEOUT=30000
      - SPRING_DATASOURCE_HIKARI_IDLE_TIMEOUT=600000
      - SPRING_DATASOURCE_HIKARI_MAX_LIFETIME=900000
      - SPRING_DATASOURCE_HIKARI_POOL_NAME=HikariPool-SyslogConsumer
      - SPRING_DATASOURCE_HIKARI_AUTO_COMMIT=false
      - SPRING_DATASOURCE_HIKARI_SCHEMA=public
      # Redis配置
      - SPRING_REDIS_HOST=192.168.4.26
      - SPRING_REDIS_PORT=6379
      - SPRING_REDIS_PASSWORD=123456
      - SPRING_REDIS_DATABASE=0
      - SPRING_REDIS_TIMEOUT=2000
      - SPRING_CACHE_REDIS_TIME_TO_LIVE=600000
      # Kafka配置
      - SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS=192.168.4.26:9092
      - SPRING_KAFKA_CONSUMER_GROUP_ID=agent-syslog-group
      - SPRING_KAFKA_CONSUMER_AUTO_OFFSET_RESET=latest
      - SPRING_KAFKA_CONSUMER_ENABLE_AUTO_COMMIT=false
      - SPRING_KAFKA_CONSUMER_TOPIC=agenet-syslog-topic
      - SPRING_KAFKA_CONSUMER_MAX_POLL_RECORDS=1000
      - SPRING_KAFKA_LISTENER_ACK_MODE=manual
      - SPRING_KAFKA_LISTENER_CONCURRENCY=2
      - SPRING_KAFKA_LISTENER_TYPE=batch
      # InfluxDB配置
      - INFLUXDB_URL=http://192.168.4.26:8087
      - INFLUXDB_TOKEN=LFjXZyRxTf1V84oN-wwjhSjS4qIK-ZMoHzQJB67ir3qHNSBVJbMcTkPuNmM0cNxvzFEDWLYNzrz1VJKMitY5hw==
      - INFLUXDB_ORG=influxdb
      - INFLUXDB_BUCKET=yelangbucket
      - INFLUXDB_BATCH_SIZE=1000
      - INFLUXDB_FLUSH_INTERVAL=1000
      - INFLUXDB_CONNECTION_TIMEOUT=30s
      - INFLUXDB_CONNECTION_READ_TIMEOUT=30s
      - INFLUXDB_CONNECTION_WRITE_TIMEOUT=60s
      # 定时任务配置
      - SPRING_TASK_SCHEDULING_POOL_SIZE=10
      # 日志配置
      - LOGGING_LEVEL_COM_COMMON_SCHEDULE=INFO
      - LOGGING_LEVEL_COM_COMMON_SERVICE=INFO

      # JVM配置
      - JAVA_OPTS=-Xms1024m -Xmx4096m -XX:+UseG1GC -XX:MaxGCPauseMillis=200
    ports:
      - "8289:8289"
    volumes:
      - /home/syslog/logs:/app/logs
    networks:
      - xdr-network
  #
# ============================================
# 网络配置
# ============================================
networks:
  xdr-network:
    driver: bridge

