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

version: '3.8'

services:
  # ============================================
  # Syslog Consumer - 数据消费服务 (平台端)
  # ============================================
  syslog-consumer:
    build:
      context: ./consumer-dm
      dockerfile: Dockerfile
    image: syslog-consumer-dm:v1.2.2
    container_name: syslog-consumer-dm
    restart: unless-stopped
    environment:
      # 环境配置
      - SPRING_PROFILES_ACTIVE=prod
      - TZ=Asia/Shanghai
      # 数据库配置
      - SPRING_DATASOURCE_URL=jdbc:dm://192.168.4.99:5237
      - SPRING_DATASOURCE_USERNAME=SYSDBA
      - SPRING_DATASOURCE_PASSWORD=caZ2TcmXNSW8L2Ap
      - SPRING_DATASOURCE_DRIVER_CLASS_NAME=dm.jdbc.driver.DmDriver
      - SPRING_DATASOURCE_HIKARI_SCHEMA=PUBLIC
      # 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

      # Redis配置
      - SPRING_REDIS_HOST=192.168.4.99
      - SPRING_REDIS_PORT=6379
      - SPRING_REDIS_PASSWORD=redis_GdGWte
      - SPRING_REDIS_DATABASE=0
      - SPRING_REDIS_TIMEOUT=2000
      - SPRING_CACHE_REDIS_TIME_TO_LIVE=600000
      # Kafka配置
    # Kafka配置
      - SPRING_KAFKA_CONSUMER_BOOTSTRAP_SERVERS=192.168.4.99:9092
      - SPRING_KAFKA_CONSUMER_GROUP_ID=agent-syslog-topic
      - SPRING_KAFKA_CONSUMER_AUTO_OFFSET_RESET=latest
      - SPRING_KAFKA_CONSUMER_ENABLE_AUTO_COMMIT=false
      - SPRING_KAFKA_CONSUMER_TOPIC=agent-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.99:8087
      - INFLUXDB_TOKEN=JsUyvU8vhQEFlMM_el4Drm87fyh707IhwJNsPBucPghSdbVmdQ-UvmPcyP5NTzWxsRfEz0T51Rw4ebZUuUrmZg==
      - 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
      # Elasticsearch配置
      - SPRING_ELASTICSEARCH_URIS=http://192.168.1.174:9200
      - SPRING_ELASTICSEARCH_USERNAME=CONTAINER_NAME
      - SPRING_ELASTICSEARCH_PASSWORD=t2NZCiajmdazxBrF
      - SPRING_ELASTICSEARCH_CONNECTION_TIMEOUT=10s
      - SPRING_ELASTICSEARCH_SOCKET_TIMEOUT=30s
      # API配置
      - INTERLOCKING_API_KEY=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
      - INTERLOCKING_API_BASE_URL=http://192.168.4.99:8089/xdrservice/interlocking
      # 探针心跳配置
      - PROBE_HEARTBEAT_ENABLED=true
      - PROBE_HEARTBEAT_OFFLINE_THRESHOLD_MINUTES=10
      - PROBE_STATUS_CHECK_CRON=0 */10 * * * ?
      - PROBE_HEARTBEAT_TENANT_ID=000000
      - PROBE_HEARTBEAT_HISTORY_KEEP_DAYS=10
      - PROBE_HEARTBEAT_HISTORY_CLEANUP_ENABLED=true
      - PROBE_HISTORY_CLEANUP_CRON=0 0 1 * * ?
      # 告警健康检查配置
      - ALARM_HEALTH_CHECK_ALARM-HOURS=4
      - ALARM_HEALTH_CHECK_ALARM-VISIT-HOURS=2
      - ALARM_HEALTH_CHECK_ENABLED=true
      # 关联分析规则配置
      - ANALYSIS_REALTIME_ENABLED=true
      - ANALYSIS_REALTIME_CHECK_INTERVAL_SECONDS=10

      # 关联分析规则达梦安全版子查询模式开关（默认false，生产环境达梦安全版设为true）
      # true → 使用 RealtimeAnalysisEngineDm，子查询包装SQL，适配 GROUP BY 不支持自定义函数
      # false → 使用 RealtimeAnalysisEngine，平铺SQL（原有行为）
      - ANALYSIS_DB_DAMENG_SUBQUERY_MODE=false
      # 分区表检查配置
      - PARTITION_CHECK_TOMORROW_ENABLED=true
      - PARTITION_CHECK_FUTURE_DAYS=7
      - PARTITION_AUTO_CREATE=true
      # 定时任务配置
      - SPRING_TASK_SCHEDULING_POOL_SIZE=10
      # 日志配置
      - LOGGING_LEVEL_COM_COMMON_SCHEDULE=INFO
      - LOGGING_LEVEL_COM_COMMON_SERVICE=INFO
      # ETL配置
      - ETL_BATCH_PAGE_SIZE=1000
      - ETL_BATCH_INSERT_BATCH_SIZE=500
      - ETL_SCHEDULE_CRON=0 0 2 * * ?

    ports:
      - "8089:8089"
    volumes:
      - /home/syslog/logs:/app/logs
    networks:
      - xdr-network
    privileged: true
# ============================================
# 网络配置
# ============================================
networks:
  xdr-network:
    driver: bridge

