prometheus.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. rule_files:
  2. - "alert_rules.yml"
  3. # 全局配置
  4. global:
  5. scrape_interval: 15s
  6. evaluation_interval: 15s
  7. # 抓取配置列表
  8. scrape_configs:
  9. # 1. 抓取 Prometheus 自身的监控数据
  10. - job_name: 'prometheus'
  11. static_configs:
  12. - targets: ['localhost:9090']
  13. # 2. 抓取服务器基础监控数据 (Node Exporter)
  14. - job_name: 'node-exporter'
  15. static_configs:
  16. - targets: ['192.168.0.181:9100', '192.168.0.182:9100', '192.168.0.208:9100', '192.168.0.209:9100']
  17. # 3. 新增:抓取 Docker 容器监控数据 (cAdvisor)
  18. - job_name: 'cadvisor'
  19. # cAdvisor 的默认指标路径也是 /metrics,所以这里不需要特意写 metrics_path
  20. static_configs:
  21. - targets: ['192.168.0.181:9099', '192.168.0.182:9099', '192.168.0.208:9099', '192.168.0.209:9099']
  22. labels:
  23. cluster: 'docker-swarm' # 可选:添加自定义标签方便在 Grafana 中过滤
  24. # 4. 抓取自定义微服务
  25. # 1. 认证服务 (Auth Service)
  26. - job_name: 'springboot-auth'
  27. metrics_path: '/api/auth/actuator/prometheus' # 显式指定完整的监控路径
  28. static_configs:
  29. - targets: ['192.168.0.181:6001']
  30. labels:
  31. app: 'auth-service'
  32. # 2. 用户服务 (User Service)
  33. - job_name: 'springboot-user'
  34. metrics_path: '/api/user/actuator/prometheus' # 显式指定完整的监控路径
  35. static_configs:
  36. - targets: ['192.168.0.181:6004']
  37. labels:
  38. app: 'user-service'
  39. # 3. 内容服务 (Content Service)
  40. - job_name: 'springboot-content'
  41. metrics_path: '/api/content/actuator/prometheus' # 显式指定完整的监控路径
  42. static_configs:
  43. - targets: ['192.168.0.181:6005']
  44. labels:
  45. app: 'content-service'