# docker-prometheus-scaffold **Repository Path**: fanjialing/docker-prometheus-scaffold ## Basic Information - **Project Name**: docker-prometheus-scaffold - **Description**: No description available - **Primary Language**: Docker - **License**: AFL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2022-04-25 - **Last Updated**: 2022-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 说明 本工程以docker-compose方式启动一个基于prometheus、grafana的基础监控框架。 如图所示,启动后,将创建如下5个容器: ![框架示意](./img/prometheus基础监控框架.png) - prometheus(prometheus:latest),prometheus server,用于采集(pull方式)监控指标; - grafana (grafana:latest),用于对监控指标图形化展示的度量分析和可视化工具; - mysql(mysql:5.7),作为Grafana配置和图表的存储方式,替换原默认的sqlite; - pushgateway(pushgateway:latest),作为采用push方式监控的应用与prometheus server之间的指标数据中转站; - influxdb(influxdb:latest),作为prometheus server监控指标数据的后端存储时序数据库; # quick start >以下步骤在MacOS验证通过 1. 克隆并修改配置 克隆工程(假设工作目录位于 ~/Develop/prometheus) ```shell $ mkdir -p ~/Develop/prometheus $ cd ~/Develop/prometheus # 克隆工程并重命名为docker $ git clone https://gitee.com/shiyunlai/docker-prometheus-scaffold.git docker ``` 修改 docker/prometheus/config/mx-nodes.json文件中的IP为宿主机实际IP ```shell # 查看本机IP $ ifconfig en0 ``` 启动 ```shell $ cd ~/Devlop/prometheus/docker $ docker-compose up ``` # 准备验证模拟数据 为了更好的验证,需要一些指标数据,可启动以下环境进行模拟提供: 1. 启动一个node_exporter - 下载[node_exporter-1.0.0-rc.0.darwin-amd64.tar.gz](https://github.com/prometheus/node_exporter/releases/download/v1.0.0-rc.0/node_exporter-1.0.0-rc.0.darwin-amd64.tar.gz) - 解压 tar -zxvf node_exporter-1.0.0-rc.0.darwin-amd64.tar.gz - 启动 ./node_exporter-1.0.0-rc.0.darwin-amd64/node_exporter 2. 下载并启动[example-prometheus-nodejs](https://gitee.com/shiyunlai/example-prometheus-nodejs.git) # 验证 1. 检查prometheus 访问 http://IP:9090/targets ![targets](./img/验证targets.png) 1. 检查grafana 访问(admin/admin) http://IP:3000 ![targets](./img/验证grafana.png) 其中准备好了三个dashboard - megapro ,监控宿主机的运行情况,需要在本地启动一个 node_exporter - Mysql详细统计,监控docker中的mysql容器,执行docker-compose up时,会同时启动mysql容器 - example prometheus nodejs,监控一个nodejs应用,该应用的源码, # 更多 - [对mysql进行监控](./readmore/monitor-mysql.md) - [使用域名而非IP](./readmore/use-domain-name.md) # 特别说明 >本工程是对[【监控】Prometheus+Grafana监控简介](https://www.jianshu.com/p/413fd42ae660)的学习总结,同时也是对文章后半部分例子的补充。 >感谢作者[whaike](https://www.jianshu.com/u/3fbb887f05d0)