环境信息
Prometheus 组件
下载 & 安装
通过指定配置文件prometheus.yml启动Prometheus
查看采集到的性能指标
查看prometheus规则
查看监控对象
SpringBoot集成Prometheus
pom.xml
配置文件
实例化MeterRegistryCustomizer
打包,上传到服务器上
Prometheus 修改配置文件prometheus.yml 接入该工程
Grafana 组件
下载 & 安装 & 启动Grafana
Grafana 接入Prometheus 的数据
Step1 添加Prometheus 数据源
Step2 设置相关信息
Step3 导入想要的dashboards
OS: Centos7 (防火墙已经关闭)
IP: 192.168.31.34
APP: Spring Boot 2.1.3搭建的演示环境
官网: https://prometheus.io/
下载地址: https://prometheus.io/download/
官方文档: https://prometheus.io/docs/prometheus/latest/getting_started/
Prometheus是一套开源的监控&报警&时间序列数据库的组合,基于应用的metrics来进行监控的开源工具 。
更多信息请参考官网介绍: https://prometheus.io/docs/introduction/overview/
官网下载速度太慢,我这里就没有使用最新版本,而是从 http://cactifans.hi-www.com 下载了 prometheus-2.1.0的版本

配置文件官方说明: https://prometheus.io/docs/prometheus/latest/configuration/configuration/
默认情况下,Prometheus会监控自己本身。
访问 http://192.168.31.34:9090/metrics
太多了,真是没法看,还好有个弱弱的图形页面 (待会整合到Grafana 中就方便看了)
访问: http://192.168.31.34:9090/graph
选中某个指标,点击Execute . 超多指标可以查看 …
如果使用properties
方便起见,我们就在启动类中实例化吧
右键–Run As – Maven build ,输入 <code>clean package</code>
服务器上启动该jar即可
增加如下配置:
重启Prometheus
访问 http://192.168.31.34:9090/targets
查看配置文件
服务自动发现
官网:https://grafana.com/
下载地址: https://grafana.com/grafana/download
入门:http://docs.grafana.org/guides/getting_started/
刚才也说了,Prometheus 的可视化功能比较弱,这里我们来接入Grafana 。
Grafana是一个跨平台的开源的度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。它主要有以下六大特点:
展示方式:快速灵活的客户端图表,面板插件有许多不同方式的可视化指标和日志,官方库中具有丰富的仪表盘插件,比如热图、折线图、图表等多种展示方式;
数据源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等;
通知提醒:以可视方式定义最重要指标的警报规则,Grafana将不断计算并发送通知,在数据达到阈值时通过Slack、PagerDuty等获得通知;
混合展示:在同一图表中混合使用不同的数据源,可以基于每个查询指定数据源,甚至自定义数据源;
注释:使用来自不同数据源的丰富事件注释图表,将鼠标悬停在事件上会显示完整的事件元数据和标记;
过滤器:Ad-hoc过滤器允许动态创建新的键/值过滤器,这些过滤器会自动应用于使用该数据源的所有查询。
官网下载速度太慢,我这里就没有使用最新版本,而是从 http://cactifans.hi-www.com 下载了 grafana-5.4.2-1.x86_64.rpm的版本
配置文件 /etc/grafana/grafana.ini , 默认3000端口,按需修改
访问 http://192.168.31.34:3000/login
默认的用户名和密码为 admin/admin
如何将 Prometheus 数据 添加到 Grafana 中,如下
Prometheus 官方指导 : https://prometheus.io/docs/visualization/grafana/
选择 Prometheus
看板地址: https://grafana.com/dashboards
可筛选
https://grafana.com/dashboards/4701
导入