由于单位项目,部分业务以及服务器需要做到实时监控,便找了行业较为前沿流行的技术进行摸索,经过部署实践,做以总结,将小小心得分享,也便于日后查看;
本文采取一键安装,一键卸载,文中脚本可以直接使用,搭建环境如下:
Linux 麒麟OS + 红莲花浏览器 + 神通数据库
项目地址在下方
sringboot项目搭建(略)
添加actuator,prometheus依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
编写application文件
#应用端口
server.port=8081
#监控端口
management.server.port=8100
#设置上下文路径
server.servlet.context-path=/monitor
management.server.servlet.context-path=${server.servlet.context-path}
#监控所包含的内容
manag