配置样例

Prometheus 的配置参数比较多,但是个人使用较多的是 global, rules, scrap_configs, statstic_config, rebel_config 等。

我平时使用的配置文件大致为这样:

  1. global:
  2. scrape_interval: 15s # By default, scrape targets every 15 seconds.
  3. evaluation_interval: 15s # By default, scrape targets every 15 seconds.
  4. rule_files:
  5. - "rules/node.rules"
  6. scrape_configs:
  7. - job_name: 'prometheus'
  8. scrape_interval: 5s
  9. static_configs:
  10. - targets: ['localhost:9090']
  11. - job_name: 'node'
  12. scrape_interval: 8s
  13. static_configs:
  14. - targets: ['127.0.0.1:9100', '127.0.0.12:9100']
  15. - job_name: 'mysqld'
  16. static_configs:
  17. - targets: ['127.0.0.1:9104']
  18. - job_name: 'memcached'
  19. static_configs:
  20. - targets: ['127.0.0.1:9150']