文章目录
- 1、promethues安装
- 2、node-exporter安装
- 3、grafana安装
- 4、配置promethues监控node节点
- 5、grafana操作
- 外传
Docker 镜像下载地址: https://hub.docker.com
比较好的hub.docker.com///-- https://hub.docker.com/u/bitnami
grafana监控面板:https://grafana.com/grafana/dashboards
1、promethues安装
docker pull bitnami/prometheus:2.48.1
配置文件下载:https://prometheus.io/download/
如果需要授权相关文件夹权限,可以参考下面的命令
chmod -R 777 /home/docker_data/monitor/prometheus/data
chmod -R 777 /home/docker_data/monitor/prometheus/rules
chmod -R 777 /home/docker_data/monitor/prometheus/conf
先去掉挂在目录的data,rules,config
docker run -itd --name prometheus --restart=always -p 9090:9090 -v /etc/localtime:/etc/localtime bitnami/prometheus:2.48.1
启动后会报错:
查看日志:docker logs prometheus
err="open /opt/bitnami/prometheus/data/queries.active: permission den
拷贝配置文件(也可以直接下载配置文件prometheus.yml)
docker cp prometheus:/opt/bitnami/prometheus/conf/prometheus.yml /home/docker_data/monitor/prometheus/conf
添加挂载目录启动
docker run -itd --name prometheus --restart=always -p 9090:9090 -v /etc/localtime:/etc/localtime -v /home/docker_data/monitor/prometheus/data:/opt/bitnami/prometheus/data -v /home/docker_data/monitor/prometheus/conf:/opt/bitnami/prometheus/conf -v /home/docker_data/monitor/prometheus/rules:/opt/bitnami/prometheus/rules bitnami/prometheus:2.48.1
查看prometheus节点: http://192.168.1.231:9090/targets?search=
2、node-exporter安装
docker pull bitnami/node-exporter:1.7.0
docker run -itd --name node-exporter --restart=always -p 9100:9100 -v /etc/localtime:/etc/localtime -v /home/docker_data/monitor/node-exporter/proc:/host/proc:ro -v /home/docker_data/monitor/node-exporter/sys:/host/sys:ro -v /home/docker_data/monitor/node-exporter/:/rootfs:ro bitnami/node-exporter:1.7.0
3、grafana安装
docker pull grafana/grafana:10.1.6
docker run -itd --name grafana --restart=always -p 3000:3000 -v /etc/localtime:/etc/localtime -v /home/docker_data/monitor/grafana:/var/lib/grafana grafana/grafana:10.1.6
初始化密码:admin/admin. 修改后:lwd123456
访问地址:http://192.168.1.231:3000/
admin/lwd123456
如果admin密码忘记了,那么可以执行:grafana-cli admin reset-admin-password admin123,修改密码
4、配置promethues监控node节点
vim prometheus.yml
在Prometheus配置文件按以下内容修改:
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: ['localhost:9090']
labels:
instance: prometheus
- job_name: linux-231
static_configs:
- targets: ['192.168.1.231:9100'] #被监控端的IP地址和端口号(有多个被监控端可用 逗号 隔开)
- job_name: linux-230
static_configs:
- targets: ['192.168.1.230:9100']
监控node-explorter ,模版:12884
5、grafana操作
官网:https://grafana.com/grafana/dashboards
模版下载:https://grafana.com/grafana/dashboards/12884-1-node-exporter-for-prometheus-dashboard-cn-v20200628/
在grafana仪表盘中导入12884模块,如果没有数据,可能是版本或者其他原因,尝试升级模块
查看promethues多少job节点
http://192.168.1.231:9090/targets
模版详情:
https://grafana.com/grafana/dashboards/12633-linux/
监控linux ,模版:12633/10180
外传
😜 原创不易,如若本文能够帮助到您的同学
🎉 支持我:关注我+点赞👍+收藏⭐️
📝 留言:探讨问题,看到立马回复
💬 格言:己所不欲勿施于人 扬帆起航、游历人生、永不言弃!🔥