Prometheus

按照官网的提示安装好Docker并配置好国内Docker加速
Docker:https://docs.docker.com/engine/install/centos/
国内加速:https://yeasy.gitbooks.io/docker_practice/install/mirror.html

提前准备好配置文件

  1. #创建一个存放Prometheus配置文件的目录
  2. mkdir -p /docker/prometheus
  3. #主配置文件
  4. vim /docker/prometheus/prometheus.yml
  5. # my global config
  6. global:
  7. scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  8. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  9. # scrape_timeout is set to the global default (10s).
  10. # Alertmanager configuration
  11. alerting:
  12. alertmanagers:
  13. - static_configs:
  14. - targets:
  15. # - alertmanager:9093
  16. # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
  17. rule_files:
  18. # - "first_rules.yml"
  19. # - "second_rules.yml"
  20. # A scrape configuration containing exactly one endpoint to scrape:
  21. # Here it's Prometheus itself.
  22. scrape_configs:
  23. # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  24. - job_name: 'prometheus'
  25. # metrics_path defaults to '/metrics'
  26. # scheme defaults to 'http'.
  27. static_configs:
  28. - targets: ['10.0.0.220:9090']

使用Docker启动

  1. docker run --name prometheus -d -p 9090:9090 \
  2. -v /docker/prometheus/:/etc/prometheus/ \
  3. prom/prometheus

浏览器打开对应的服务器IP:9090即可

Grafana

官方提供的Web UI太简陋,用来调试和直接查询时够用,但无法作为一个强大的监控系统,引入Grafana提供Web界面支持

  1. docker run --name grafana -d -p 3000:3000 \
  2. -v /docker/grafana:/var/lib/grafana \
  3. grafana/grafana

感谢

参考文档:https://www.aneasystone.com/archives/2018/11/prometheus-in-action.html