Spring boot 2.0 + Actuator 应用健康管理

关于spring-boot-actuator

注:文章内容转载自https://blog.csdn.net/qq_36666651/article/details/80696810

springboot的Actuator提供了运行状态监控的功能,可以通过REST、远程Shell和JMX方式来查看。 

使用方式

pom文件中添加相关依赖

<!-- actuator -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

然后在application.properties中配置相关参数

#actuator端口
management.server.port=8310

#修改访问路径,2.0之前默认是/,2.0默认是/actuator
management.endpoints.web.base-path=/actuator

#开放所有页面节点 ,默认只开启了health、info两个节点
management.endpoints.web.exposure.include=*

#显示健康具体信息,默认不会显示详细信息  
management.endpoint.health.show-details=always

就可以完成对actuator的基本配置,项目即可访问健康信息,访问方式为 localhost:9001/actuator/{name}

其中:

localhost

IP地址

9001

management.server.port设置的值

actuator

management.endpoints.web.base-path的值

{name}

节点名称,例如localhost:9001/actuator/health请求应用的健康信息

 

 

 

 

 

spring boot官方文档中可知,所有的节点如下:(翻译为机翻,可能不准,请自行查看官网)

自定义api的访问路径

可以通过在application.properties文件中添加相应的参数用于配置api的访问路径

#basic access path, default:/actuator

management.endpoints.web.base-path=/api

#management.endpoints.web.path-mapping.xx change endpoint path

management.endpoints.web.path-mapping.health=/sys-health

management.endpoints.web.path-mapping.info=/sys-info

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值