安装 Master
首先把所以机器名配置在 /etc/hosts 文件中。
配置文件:/etc/prometheus/prometheus.yml
内容如下:
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node_export'
static_configs:
- targets:
- server1:9100
- server2:9100
启动命令
docker run \
--name prometheus \
-d -p 9090:9090 \
-v /etc/hosts:/etc/hosts \
-v /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus \
--web.read-timeout=5m \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/prometheus \
--web.max-connections=512 \
--storage.tsdb.retention=30d \
--query.timeout=2m
安装 Grafana
docker run --name grafana -d -p 3000:3000 grafana/grafana
初始登陆账号密码都是 admin
可以使用模版ID:10180
安装 node_export
sudo wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz;
sudo tar xvfz node_exporter-0.18.1.linux-amd64.tar.gz;
mv node_exporter-0.18.1.linux-amd64/node_exporter /usr/local/bin/
node_exporter &
或者使用 docker
docker run -d \
--net="host" \
--pid="host" \
-v "/:/host:ro,rslave" \
quay.io/prometheus/node-exporter \
--path.rootfs=/host