基于docker部署Prometheus+Grafana
作者:互联网
前言:
目前我们公司新的系统都采用了容器部署,传统的win虚拟机技术架构要做升级,对应的监控系统(scom)也需要升级,我这边选择了Prometheus+Grafana进行学习记录
箱识服务器采用的是zabbix监控方案:
Prometheus和zabbix对比
Docker安装Prometheus
10.5.1.235:安装Prometheus、Grafana、node_exporter和Cadvisor
10.5.1.236:安装node_exporter和Cadvisor
node_exporter – 用于机器系统数据收集
Cadvisor 用于收集宿主机上的docker容器数据
拉取镜像
docker pull prom/node-exporter
docker pull google/cadvisor
docker pull prom/prometheus
docker pull grafana/grafana
启动
docker run -d --name node-exporter --restart=always -p 9100:9100 -v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" -v "/:/rootfs:ro" prom/node-exporter
docker run -v /:/rootfs:ro -v /var/run:/var/run:rw -v /sys:/sys:ro -v /var/lib/docker/:/var/lib/docker:ro -v /dev/disk/:/dev/disk:ro -p 8080:8080 -d --name=cadvisor --restart=always google/cadvisor:latest
docker run -d --name prometheus --restart=always -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
docker run -d -p 3000:3000 --name grafana -v /home/grafana:/var/lib/grafana grafana/grafana
配置Prometheus监控节点
mkdir /home/prometheus
cd /home/prometheus/
vim prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['10.5.1.235:9090']
labels:
instance: prometheus
- job_name: linux
static_configs:
- targets: ['10.5.1.235:9100']
labels:
instance: linux10.5.1.235
- targets: ['10.5.1.236:9100']
labels:
instance: linux10.5.1.236
- job_name: cadvisor
static_configs:
- targets: ['10.5.1.235:8080']
labels:
instance: cAdvisor10.5.1.235
- targets: ['10.5.1.236:8080']
labels:
instance: cAdvisor10.5.1.236
- job_name: mysqld
static_configs:
- targets: ['10.5.1.235:9104']
labels:
instance: mysql-exporter
如果正常就可以看到对应的页面
http://10.5.1.235:9090/targets:查看对应的监控节点
http://10.5.1.235:8080/metrics:查看采集的日志
http://10.5.1.236:8080/metrics:查看采集的日志
http://10.5.1.235:9100/metrics:查看采集的日志
http://10.5.1.236:9100/metrics:查看采集的日志
进入grafana:http://10.5.1.235:3000/,默认密码adminadmin
配置连接Prometheus
点击Setting——Add data source----选择Prometheus,输入IP和端口,我这边就是10.5.1.235:9090
配置展示模板
1.服务器系统性能监控:8919
2.微服务性能监控:4701
3.docker环境性能监控:893
4.nacos性能监控:13221
5.mysql性能监控:9362
最终效果如下:
标签:1.235,name,Prometheus,Grafana,prometheus,10.5,docker,grafana 来源: https://www.cnblogs.com/mlwork/p/16497851.html