上一篇我们已经搭建好了prometheus、granfana,那我们要添加新的节点应该怎么做呢?下面我们就来操作一波。
在要监控的node节点安装docker-io,做加速配置、拉取node-exporter镜像
安装docker-io
yum install docker-io -y
配置加速下载镜像
vim /etc/docker/daemon.json
{
“registry-mirrors”: [
“https://hub-mirror.c.163.com”,
“https://mirror.baidubce.com”
]
}
开启docker,加上开机自启
systemctl start docker && systemctl enable docker
拉取node-exporter镜像
docker pull prom/node-exporter
创建node实例,有多少台就在多少台主机上执行
docker run -d -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" --net="host" prom/node-exporter
再到prometheus服务器上编辑prometheus.yml
vim /opt/prometheus/prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:- targets: [‘192.168.100.17:9090’]
labels:
instance: prometheus
- targets: [‘192.168.100.17:9090’]
一台主机加一个模块
-
job_name: linux # 节点1
static_configs:- targets: [‘192.168.100.17:9100’]
labels:
instance: 192.168.100.17
- targets: [‘192.168.100.17:9100’]
-
job_name: cj1 # 节点2
static_configs:- targets: [‘192.168.100.12:9100’]
labels:
instance: 192.168.100.12
- targets: [‘192.168.100.12:9100’]
-
job_name: cj2 # 节点3
static_configs:- targets: [‘192.168.100.16:9100’]
labels:
instance: 192.168.100.16
最后一步,重启prometheus容器加载yml文件(不知道有没有不用重启容器加载yml文件的办法,有的话请在下方留言,教教小弟,多谢_)
- targets: [‘192.168.100.16:9100’]
docker restart prometheus的容器名称
访问host_ip:9090
可以看到,节点都添加成功了。