docker安装prometheus、node-exporter
1、pull 镜像
docker pull prom/prometheus
docker pull prom/node-exporter
2、启动node-exporter,注意时间同步,避免查询不到指标
docker run -d -p 9100:9100 \
-v "/proc:/host/proc" \
-v "/sys:/host/sys" \
-v "/:/rootfs" \
-v "/etc/localtime:/etc/localtime" \
--net=host \
prom/node-exporter \
--path.procfs /host/proc \
--path.sysfs /host/sys \
--collector.filesystem.ignored-mount-points "^/(sys|proc|dev|host|etc)($|/)"
3、编辑prometheus配置文件,用于后续启动prometheus指定配置文件
创建文件 /usr/local/prometheus/data/prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60sscrape_configs:
- job_name: prometheus
static_configs:
- targets: ['192.168.133.135:9090']
labels:
instance: prometheus- job_name: node
static_configs:
- targets: ['192.168.133.135:9100']
labels:
instance: node
4、启动prometheus容器,注意时间同步,避免查询不到指标
注意指定配置文件 /usr/local/prometheus/data/prometheus.yml
docker run -d -p 9090:9090 \
-v /usr/local/prometheus/data/prometheus.yml:/etc/prometheus/prometheus.yml \
-v "/etc/localtime:/etc/localtime" \
--name prometheus \
--net=host \
prom/prometheus:latest
5、打开浏览器,访问node-exporter界面:http://192.168.133.135:9100/metrics
6、打开浏览器,访问prometheus界面:http://192.168.133.135:9090/targets,并且检查组件健康情况