spring boot(21)-actuator监控
来源:互联网 发布:linux搭建java环境 编辑:程序博客网 时间:2024/06/05 16:54
actuator是spring boot中非常重要的一大功能,主要用于在项目运行时,查看运行中的各种配置及参数等
pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
查看端点
敏感配置
#设置所有端点不敏感endpoints.sensitive=false#设置单个端点(/beans)不敏感endpoints.beans.sensitive=false以上两个配置只需要一个就可以开启查看http://localhost:8080/beans
部分端点介绍
/autoconfig:自动配置,显示 哪些自动配置生效,哪些没生效,以及生效的条件是什么
/configprops:参数配置,显示当前环境下,spring boot可配置的properties参数有哪些
/beans:注入的Bean,显示当前spring boot中注入了哪些bean
注意:以上三个是理解和学习spring boot非常重要的端点,下面会进一步介绍这三个
/dump:活动线程
/env:环境属性
/health:健康检查
/info:定制信息
/mappings:URI路径,在这里可以看到有哪些端点
/metrics:查看内存、CPU核心等系统参数
/trace:用户请求信息
/loggers:日志
/env/{name:.*}:像这种端点,后面带有一个name,这是指获取env中名字为name的那一个参数的值,比如http://localhost:8080/env/local.server.port
Chrome插件
先说明一下,上图中我用的是Chrome浏览器,安装了JSONView插件,查看json时会自动格式化,可以看的更清楚,而且可以收起。另外我还装了tabbed postman-rest client插件,用于模拟post请求,因为有些端口安全级别高,只允许POST请求,后面会讲。怎么安装Chrome插件这里不讨论,网上找很简单,不过装Chrome插件需要翻墙。
/autoconfig
查看自动配置,在当前程序中某些自动配置生效以及不生效的原因这个图是利用JSONView插件将json数据全部收起到最高级别
positiveMatches:是当前自动配置生效的bean
negativeMatches:是当前自动配置规则不符,没有配置的bean
展开positiveMatches有上面这一段,这就是默认tomcat连接池的自动配置原因,详细意思如果你不懂,我在这里简单几句话也讲不清楚。不过我在12篇有对这个自动配置的详细讲解,只要你看懂了第12篇,再对照着看这里,自然就会明白。只要你能看懂positiveMatches,自然就能看懂negativeMatches
/beans
/configprops
可以查看当前的properties参数值,或者你不知道你引入的spring boot组件有哪些properties参数可以配置,也可以在这里查找 ,如下是数据源配置spring.datasource.tomcat.maxIdle = xxx
/shutdown关闭应用
/shutdown是一个特殊端点,请求这个端点可以直接关闭运行中的应用程序。我们在eclipse中也可以启动和关闭spring boot,但那属于强杀,会将没执行完的线程直接杀死,就像按电源直接关机一样,可能会造成一些问题。而/shutdown就相当于点击左下角的关机按钮,属于优雅的关机。endpoints.shutdown.enabled=true此外,这个端点只能用post请求,也就是在浏览器中请求是无效的
访问权限
如果要保证这几个端点的安全,可以使用过滤器对这些端点进行权限控制。注意拦截器对这些端点无效,具体原因我在18篇和19篇讲过。- spring boot(21)-actuator监控
- Spring Boot Actuator监控端点
- Spring Boot Actuator监控端点小结
- 使用Spring Boot Actuator监控应用
- Spring Boot Actuator监控端点小结
- spring boot actuator监控和管理
- (17)spring boot的Actuator监控使用
- spring boot admin + spring boot actuator + erueka 微服务监控
- Spring boot(14) 监控spring boot的运行spring boot actuator和spring boot admin
- 监控和管理生产环境spring boot actuator
- spring-boot actuator(监控)配置和使用
- 监控和管理生产环境spring boot actuator
- 监控和管理生产环境spring boot actuator
- spring-boot actuator(监控)配置和使用
- spring-boot actuator(监控)配置和使用
- 监控和管理生产环境spring boot actuator
- spring-boot actuator(监控)配置和使用
- 监控和管理生产环境spring boot actuator
- Java网络编程之Netty入门案例-yellowcong
- H5的css的特性及JavaScript
- 点击按钮获取listview网上数据
- 解读道德经 关于人格观 价值观 智慧观
- 如何生成二维码
- spring boot(21)-actuator监控
- 事务
- ArrayAdapter适配
- 客户端跳转与服务器端跳转的区别
- 对单选框多选框下拉框的绑定及选取操作
- 849852_十里桃花主管:网站目录收录的好处
- 弹性动画
- 双链表--简单操作
- 求字符串中不重复的最长子串的长度