Spring Boot与监控管理
概念:
通过引入spring-boot-starter-actuator,可以使用Spring Boot为我们提供的准生产环境下的应用监控和管理功能。我们可以通过HTTP,JMX,SSH协议来进行操作,自动得到审计、健康及指标信息等。
步骤:
- 引入spring-boot-starter-actuator
- 通过http方式访问监控端点
- 可进行shutdown(POST 提交,此端点默认关闭)
监控和管理端点中文对照

常用定制端点信息方法:
1.定制端点一般通过endpoints+端点名+属性名来设置。
2.修改端点id(endpoints.beans.id=mybeans)
3.开启远程应用关闭功能(endpoints.shutdown.enabled=true)
4.关闭端点(endpoints.beans.enabled=false)
5.开启所需端点
endpoints.enabled=false endpoints.beans.enabled=true
6.定制端点访问根路径
management.context-path=/manage
7.关闭http端点
management.port=-1
springboot版本:1.5.12
http://localhost:8080/info 可以查看git的配置信息
git.properties:
git.branch=master
git.commit.id=xjkd33s
git.commit.time=2017-12-12 12:12:56
application.properties:
#设置监控端点可见
management.security.enabled=false #测试redis的health
spring.redis.host=192.168.0.113 #设置localhost:8080/info的值
info.app.id=hello
info.app.version=1.0.0 #设置metrics端点不可见
#endpoints.metrics.enabled=false
endpoints.shutdown.enabled=true #设置beans的名字,改后访问路径为:localhost:8080/mybean
#endpoints.beans.id=mybean
#设置beans的访问路径,改后访问路径为:localhost:8080/bean
#endpoints.beans.path=/bean
#endpoints.beans.enabled=false
#
#endpoints.dump.path=/du # 关闭所有端点访问
#endpoints.enabled=false
# 打开beans端点的访问
#endpoints.beans.enabled=true #设置访问端点前缀
management.context-path=/manage
#设置访问端口号
management.port=8181
自定义HealthIndicator:
/*
* 自定义健康状态指示器
* 1.编写一个指示器 实现healthIndicator 接口
* 2.指示器名字 xxxxHealthIndicator
* 3.加入容器中
* */ @Component
public class MyAppHealthIndicator implements HealthIndicator {
@Override
public Health health() { //自定义的检查方法
//return Health.up().build();//代表健康
return Health.down().withDetail("msg","服务异常").build();
}
}
Spring Boot与监控管理的更多相关文章
- spring Boot(十九):使用Spring Boot Actuator监控应用
spring Boot(十九):使用Spring Boot Actuator监控应用 微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台 ...
- (39.4) Spring Boot Shiro权限管理【从零开始学Spring Boot】
在读此文章之前您还可能需要先了解: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...
- (39.3) Spring Boot Shiro权限管理【从零开始学Spring Boot】
在学习此小节之前您可能还需要学习: (39.1) Spring Boot Shiro权限管理[从零开始学Spring Boot] http://412887952-qq-com.iteye.com/b ...
- (39.2). Spring Boot Shiro权限管理【从零开始学Spring Boot】
(本节提供源代码,在最下面可以下载) (4). 集成Shiro 进行用户授权 在看此小节前,您可能需要先看: http://412887952-qq-com.iteye.com/blog/229973 ...
- (39.1) Spring Boot Shiro权限管理【从零开始学Spring Boot】
(本节提供源代码,在最下面可以下载)距上一个章节过了二个星期了,最近时间也是比较紧,一直没有时间可以写博客,今天难得有点时间,就说说Spring Boot如何集成Shiro吧.这个章节会比较复杂,牵涉 ...
- Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用
Spring Boot (十): Spring Boot Admin 监控 Spring Boot 应用 1. 引言 在上一篇文章<Spring Boot (九): 微服务应用监控 Spring ...
- Spring Boot Actuator监控使用详解
在企业级应用中,学习了如何进行SpringBoot应用的功能开发,以及如何写单元测试.集成测试等还是不够的.在实际的软件开发中还需要:应用程序的监控和管理.SpringBoot的Actuator模块实 ...
- Springboot 系列(十七)迅速使用 Spring Boot Admin 监控你的 Spring Boot 程序,支持异常邮件通知
1. Spring Boot Admin 是什么 Spring Boot Admin 是由 codecentric 组织开发的开源项目,使用 Spring Boot Admin 可以管理和监控你的 S ...
- 使用 Spring Boot Admin 监控应用状态
程序员优雅哥 SpringBoot 2.7 实战基础 - 11 - 使用 Spring Boot Admin 监控应用状态 1 Spring Boot Actuator Spring Boot Act ...
随机推荐
- Thread状态
- python学习7—函数定义、参数、递归、作用域、匿名函数以及函数式编程
python学习7—函数定义.参数.递归.作用域.匿名函数以及函数式编程 1. 函数定义 def test(x) # discription y = 2 * x return y 返回一个值,则返回原 ...
- Crane /// 向量旋转+线段树
题目大意: 给定n条首尾相接的线段的长度 第一条从0,0开始,所有线段垂直与x轴向上延伸 给定c次操作 每次操作给定 s,a 使得 由第s条线段的角度 逆时针旋转a后 达到第s+1条线段的角度 每次操 ...
- u-boot 的介绍及系统结构
u-boot 介绍 Uboot 是德国 DENX 小组的开发用于多种嵌入式 CPU 的 bootloader 程序, UBoot 不仅仅支持嵌入式 Linux 系统的引导,当前,它还支持 Net ...
- Ansible实现批量无密码登录
如果机器多,假如有一百台服务器,每台服务器登录前都得先输入yes,使用交互式的方式下发公钥的话就很麻烦(ssh-copy-id). 第一次操作需要通过密码来操作服务器,所以配置文件需要把密码配置好 a ...
- sysobjects syscolumns
在sysobjects系统表中存储着数据库的所有对象,每个对象都有一个唯一的id号进行标识.object_id就是根据对象名称返回该对象的id.反之,object_name是根据对象id返回对象名称. ...
- Python学习笔记(四)——文件永久存储
文件的永久存储 pickle模块的使用 pickle的实质就是将数据对象以二进制的形式存储 存储数据 pickle.dump(data,file) data表示想要存储的数据元素,file表示要将数据 ...
- python2与python3编码(练习)
#_author:来童星#date:2019/12/9import jsons='star'a=s.encode('utf8')print(s,type(s))# star <class 'st ...
- csp-s模拟100,101T1,T2题解
题面:https://www.cnblogs.com/Juve/articles/11799325.html 我太蒻了只会T1T2 组合: 欧拉路板子?不会呀... 然后打了个优化,防止暴栈 #inc ...
- 暑假集训test-8-26
真 noip模拟题 但是被我做得稀巴烂 新高二除了林巨做得勉强能看,其他人都做得稀巴烂 老张都要绝望了 t1.水呀水 题如其名是道水题.新建个点代表水源,跑最小生成树即可. //Achen #incl ...