rule_files: - "alert_rules.yml" # 全局配置 global: scrape_interval: 15s evaluation_interval: 15s # 抓取配置列表 scrape_configs: # 1. 抓取 Prometheus 自身的监控数据 - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] # 2. 抓取服务器基础监控数据 (Node Exporter) - job_name: 'node-exporter' static_configs: - targets: ['192.168.0.181:9100', '192.168.0.182:9100', '192.168.0.208:9100', '192.168.0.209:9100'] # 3. 新增:抓取 Docker 容器监控数据 (cAdvisor) - job_name: 'cadvisor' # cAdvisor 的默认指标路径也是 /metrics,所以这里不需要特意写 metrics_path static_configs: - targets: ['192.168.0.181:9099', '192.168.0.182:9099', '192.168.0.208:9099', '192.168.0.209:9099'] labels: cluster: 'docker-swarm' # 可选:添加自定义标签方便在 Grafana 中过滤 # 4. 抓取自定义微服务 # 1. 认证服务 (Auth Service) - job_name: 'springboot-auth' metrics_path: '/api/auth/actuator/prometheus' # 显式指定完整的监控路径 static_configs: - targets: ['192.168.0.181:6001'] labels: app: 'auth-service' # 2. 用户服务 (User Service) - job_name: 'springboot-user' metrics_path: '/api/user/actuator/prometheus' # 显式指定完整的监控路径 static_configs: - targets: ['192.168.0.181:6004'] labels: app: 'user-service' # 3. 内容服务 (Content Service) - job_name: 'springboot-content' metrics_path: '/api/content/actuator/prometheus' # 显式指定完整的监控路径 static_configs: - targets: ['192.168.0.181:6005'] labels: app: 'content-service'