部署前提:
1.centos7 系统,关闭防火墙
2.已经安装docker
部署过程
1.编辑prometheus配置文件
vim prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
- 192.168.10.15:9093 #替换为当前主机ip
rule_files:
- "rules/*.yml"
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['192.168.10.15:9100']
2.安装Prometheus
docker run --privileged=true \
--restart=always \
--name=prometheus -d \
-p 9090:9090 \
-v /root/prometheus/:/etc/prometheus/ \
-v /etc/localtime:/etc/localtime:ro \
prom/prometheus
3.部署node exporter服务
docker run -d --privileged=true \
--restart=always \
--name node_exporter \
-p 9100:9100 \
-v /etc/localtime:/etc/localtime:ro \
quay.io/prometheus/node-exporter
4.部署grafana
docker run -d --privileged=true \
--restart=always \
--name=grafana \
-p 3000:3000 \
-v /etc/localtime:/etc/localtime:ro \
grafana/grafana
5.添加数据库源
6.添加监控主机模版8919,或官网下载json文件
https://grafana.com/grafana/dashboards/8919