Prometheus
按照官网的提示安装好Docker并配置好国内Docker加速
Docker:https://docs.docker.com/engine/install/centos/
国内加速:https://yeasy.gitbooks.io/docker_practice/install/mirror.html
提前准备好配置文件
#创建一个存放Prometheus配置文件的目录mkdir -p /docker/prometheus#主配置文件vim /docker/prometheus/prometheus.yml# my global configglobal:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configurationalerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.rule_files:# - "first_rules.yml"# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:# Here it's Prometheus itself.scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: 'prometheus'# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ['10.0.0.220:9090']
使用Docker启动
docker run --name prometheus -d -p 9090:9090 \-v /docker/prometheus/:/etc/prometheus/ \prom/prometheus
Grafana
官方提供的Web UI太简陋,用来调试和直接查询时够用,但无法作为一个强大的监控系统,引入Grafana提供Web界面支持
docker run --name grafana -d -p 3000:3000 \-v /docker/grafana:/var/lib/grafana \grafana/grafana
感谢
参考文档:https://www.aneasystone.com/archives/2018/11/prometheus-in-action.html
