炎龙智能炎龙智能
AIOPS智能运维平台
AIOPS智能运维平台
  • 配置管理

配置管理

本文档详细介绍AIOPS智能运维平台的配置选项,帮助用户根据实际需求进行系统配置,以达到最佳的运行效果。

1. 配置文件结构

AIOPS平台的配置文件采用层次化的结构组织,主要包括以下几个部分:

# 数据库配置
database:  
  # 数据库连接信息

# Redis配置
redis:  
  # Redis连接信息

# 服务器配置
server:  
  # API服务配置
  # UI服务配置

# 监控配置
monitor:  
  # 数据采集配置
  # 告警配置

# 认证配置
auth:  
  # 用户认证配置
  # 权限控制配置

# 日志配置
log:  
  # 日志级别
  # 日志路径
  # 日志格式

2. 数据库配置

数据库是AIOPS平台的核心存储组件,用于存储监控数据、告警信息、用户配置等数据。

2.1 MySQL配置

database:
  # 数据库类型:mysql, postgresql等
  type: mysql
  # 数据库主机地址
  host: localhost
  # 数据库端口
  port: 3306
  # 数据库用户名
  user: aiops
  # 数据库密码
  password: your_password
  # 数据库名称
  name: aiops
  # 连接池配置
  pool:
    # 最大连接数
    max: 100
    # 最小连接数
    min: 10
    # 连接超时时间(毫秒)
    idleTimeout: 180000
    # 连接最大生存时间(毫秒)
    maxLifetime: 1800000

2.2 PostgreSQL配置

database:
  type: postgresql
  host: localhost
  port: 5432
  user: aiops
  password: your_password
  name: aiops
  # PostgreSQL特有配置
  sslMode: disable
  timezone: UTC

3. Redis配置

Redis用于缓存热点数据、存储会话信息和临时数据。

redis:
  # Redis主机地址
  host: localhost
  # Redis端口
  port: 6379
  # Redis密码
  password: your_redis_password
  # 数据库编号
  db: 0
  # 连接池配置
  pool:
    maxActive: 100
    maxWait: -1
    maxIdle: 10
    minIdle: 5
  # 连接超时时间(毫秒)
  timeout: 5000

4. 服务器配置

4.1 API服务配置

API服务是AIOPS平台的核心服务组件,提供所有的业务逻辑和数据处理功能。

server:
  api:
    # 监听地址
    host: 0.0.0.0
    # 监听端口
    port: 8080
    # 请求超时时间(秒)
    timeout: 30
    # 最大请求体大小(字节)
    maxBodySize: 10485760
    # 启用HTTPS
    https:
      enabled: false
      # HTTPS证书路径
      certFile: "/path/to/cert.pem"
      # HTTPS私钥路径
      keyFile: "/path/to/key.pem"
    # CORS配置
    cors:
      enabled: true
      allowOrigins: ["*"]
      allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
      allowHeaders: ["*"]

4.2 UI服务配置

UI服务提供Web界面访问,是用户与系统交互的主要入口。

server:
  ui:
    # 监听地址
    host: 0.0.0.0
    # 监听端口
    port: 80
    # 静态文件目录
    staticDir: "/path/to/ui/dist"
    # 启用HTTPS
    https:
      enabled: false
      certFile: "/path/to/cert.pem"
      keyFile: "/path/to/key.pem"

5. 监控配置

5.1 数据采集配置

monitor:
  # 数据采集配置
  collect:
    # 采集间隔(秒)
    interval: 10
    # 采集超时时间(秒)
    timeout: 5
    # 数据保留策略
    retention:
      # 原始数据保留天数
      raw: 7
      # 聚合数据保留天数(小时级)
      hour: 30
      # 聚合数据保留天数(天级)
      day: 365
  # 告警配置
  alert:
    # 告警检查间隔(秒)
    checkInterval: 5
    # 告警聚合窗口(秒)
    aggregateWindow: 60
    # 告警静默期(秒)
    silencePeriod: 300
    # 默认告警通知方式
    defaultNotifiers: ["email", "sms"]

5.2 告警规则配置

告警规则可以通过Web界面配置,也可以在配置文件中预设:

monitor:
  alert:
    rules:
      - name: "CPU使用率过高"
        description: "当CPU使用率持续超过90%时触发告警"
        severity: "high"
        condition: "cpu.usage > 90"
        duration: 300  # 持续时间(秒)
        notifiers: ["email", "sms"]
        tags: ["server", "performance"]
      - name: "内存使用率过高"
        description: "当内存使用率持续超过85%时触发告警"
        severity: "medium"
        condition: "memory.usage > 85"
        duration: 300
        notifiers: ["email"]
        tags: ["server", "performance"]

6. 认证与权限配置

6.1 用户认证配置

auth:
  # JWT配置
  jwt:
    # JWT密钥
    secret: "your_jwt_secret_key"
    # JWT过期时间(小时)
    expiresIn: 24
    # JWT刷新时间(小时)
    refreshIn: 720
  # 密码策略
  password:
    # 最小长度
    minLength: 8
    # 是否要求包含数字
    requireNumber: true
    # 是否要求包含小写字母
    requireLowercase: true
    # 是否要求包含大写字母
    requireUppercase: true
    # 是否要求包含特殊字符
    requireSpecial: true
  # 登录限制
  login:
    # 最大失败次数
    maxFailedAttempts: 5
    # 锁定时间(分钟)
    lockoutDuration: 30

6.2 权限控制配置

auth:
  # 角色定义
  roles:
    - name: "admin"
      description: "系统管理员"
      permissions: ["*"]
    - name: "operator"
      description: "运维操作员"
      permissions: ["monitor:view", "alert:view", "alert:handle"]
    - name: "viewer"
      description: "查看用户"
      permissions: ["monitor:view", "alert:view"]
  # 权限定义
  permissions:
    - name: "monitor:view"
      description: "查看监控数据"
    - name: "alert:view"
      description: "查看告警信息"
    - name: "alert:handle"
      description: "处理告警"
    - name: "config:manage"
      description: "管理配置"

7. 日志配置

log:
  # 日志级别:debug, info, warn, error
  level: "info"
  # 日志格式:json, text
  format: "json"
  # 日志文件路径
  file: "/var/log/aiops/aiops.log"
  # 日志文件大小限制(MB)
  maxSize: 100
  # 最大保留文件数
  maxBackups: 10
  # 最大保留天数
  maxAge: 30
  # 是否启用控制台输出
  console: true
  # 是否启用文件输出
  fileOutput: true

8. 集成配置

8.1 邮件服务配置

integration:
  email:
    # SMTP服务器地址
    host: "smtp.example.com"
    # SMTP服务器端口
    port: 587
    # 是否启用SSL/TLS
    secure: false
    # SMTP用户名
    user: "noreply@example.com"
    # SMTP密码
    password: "your_email_password"
    # 发件人
    from: "AIOPS Platform <noreply@example.com>"
    # 邮件模板目录
    templateDir: "/path/to/email/templates"

8.2 短信服务配置

integration:
  sms:
    # 短信服务提供商
    provider: "aliyun"  # aliyun, tencent
    # 阿里云配置
    aliyun:
      accessKeyId: "your_access_key_id"
      accessKeySecret: "your_access_key_secret"
      signName: "AIOPS平台"
      templateCode: "SMS_123456789"
    # 腾讯云配置
    tencent:
      secretId: "your_secret_id"
      secretKey: "your_secret_key"
      sdkAppId: "1400000000"
      templateId: "123456"
      sign: "AIOPS平台"

8.3 企业微信配置

integration:
  wecom:
    # 企业ID
    corpId: "your_corp_id"
    # 应用Secret
    appSecret: "your_app_secret"
    # 应用AgentId
    agentId: "1000001"
    # 接收消息的部门ID列表
    toParty: ["1"]
    # 接收消息的用户ID列表
    toUser: ["@all"]

8.4 Prometheus集成

integration:
  prometheus:
    # Prometheus服务器地址
    url: "http://prometheus:9090"
    # 基本认证(可选)
    basicAuth:
      enabled: false
      username: "admin"
      password: "password"
    # 抓取间隔(秒)
    scrapeInterval: 15

8.5 Grafana集成

integration:
  grafana:
    # Grafana服务器地址
    url: "http://grafana:3000"
    # API密钥
    apiKey: "your_grafana_api_key"
    # 默认组织ID
    orgId: 1

9. 性能优化配置

9.1 缓存配置

performance:
  cache:
    # 启用缓存
    enabled: true
    # 缓存类型:redis, memory
    type: "redis"
    # 缓存过期时间(秒)
    defaultExpiration: 300
    # 缓存键前缀
    keyPrefix: "aiops:"

9.2 连接池配置

performance:
  connectionPool:
    # HTTP连接池
    http:
      maxIdle: 100
      maxTotal: 200
      maxWaitMillis: 3000
    # 数据库连接池(如果未在database配置中指定)
    database:
      maxActive: 100
      maxIdle: 10
      minIdle: 5
      maxWait: 3000

10. 安全配置

10.1 SSL/TLS配置

security:
  ssl:
    # 全局启用HTTPS
    enabled: false
    # 证书路径
    certFile: "/path/to/cert.pem"
    # 私钥路径
    keyFile: "/path/to/key.pem"
    # 密码(如果私钥有密码保护)
    passphrase: ""

10.2 CORS配置

security:
  cors:
    # 启用CORS
    enabled: true
    # 允许的源
    allowOrigins: ["*"]
    # 允许的方法
    allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"]
    # 允许的头部
    allowHeaders: ["*"]
    # 是否允许凭证
    allowCredentials: true

10.3 防XSS配置

security:
  xss:
    # 启用XSS防护
    enabled: true
    # 过滤级别:low, medium, high
    level: "medium"

11. 配置文件热更新

AIOPS平台支持配置文件的热更新,修改配置后可以通过以下方式使配置生效:

11.1 通过API更新配置

curl -X PUT "http://your-server:8080/api/v1/config/reload" \
  -H "Authorization: Bearer your_token"

11.2 重启服务

对于某些核心配置(如数据库连接、服务器端口等),可能需要重启服务才能生效:

# Docker Compose部署
docker-compose restart

# 二进制部署
./bin/restart.sh

# Kubernetes部署
kubectl rollout restart deployment aiops-api -n aiops
kubectl rollout restart deployment aiops-ui -n aiops

12. 环境变量配置

AIOPS平台支持通过环境变量覆盖配置文件中的设置,环境变量的命名规则为:AIOPS_<配置路径>_<配置项>,其中路径部分用下划线分隔。

例如:

  • AIOPS_DATABASE_HOST 对应 database.host
  • AIOPS_REDIS_PASSWORD 对应 redis.password
  • AIOPS_SERVER_API_PORT 对应 server.api.port

13. 配置备份与恢复

13.1 备份配置

# 备份配置文件
cp /path/to/config.yaml /path/to/config.yaml.bak

# Docker Compose部署
docker cp aiops-api:/app/config/config.yaml /path/to/backup/config.yaml

13.2 恢复配置

# 恢复配置文件
cp /path/to/backup/config.yaml /path/to/config.yaml

# Docker Compose部署
docker cp /path/to/backup/config.yaml aiops-api:/app/config/config.yaml
docker-compose restart

14. 常见配置问题排查

14.1 数据库连接失败

  • 检查数据库主机地址和端口是否正确
  • 检查数据库用户名和密码是否正确
  • 检查数据库是否已创建
  • 检查防火墙是否允许连接

14.2 Redis连接失败

  • 检查Redis主机地址和端口是否正确
  • 检查Redis密码是否正确
  • 检查Redis是否已启动
  • 检查防火墙是否允许连接

14.3 服务启动失败

  • 检查配置文件格式是否正确(YAML格式)
  • 检查端口是否被占用
  • 查看日志文件获取详细错误信息

14.4 告警不触发

  • 检查告警规则配置是否正确
  • 检查监控数据是否正常采集
  • 检查告警通知配置是否正确
Last Updated:: 11/28/25, 3:06 PM
Contributors: sunxiaokun