actuator--基础--03--端点配置

actuator–基础–03–端点配置


1、默认暴露

在这里插入图片描述

  1. 上图配置JMX和HTTP的暴露端点。
  2. Actuator 默认只会开放 /actuator/health 和 /actuator/info这两个端点,如果要开放其他 endpoint,需要额外在 application.properties 中做设置。

2、暴露配置(application.properties)

# 暴露所有 HTTP的endpoints(不包含shutdown)
#management.endpoints.web.exposure.include=*

# 只暴露指定 HTTP的endpoint
# 这里只暴露 /actuator/beans和/actuator/mappings 端点
#management.endpoints.web.exposure.include=beans,mappings

## exclude 用来关闭某些endpoints
## exclude 通常会跟include一起用,先include全部endpoints,然后再exclude某些endpoints 
# 这里暴露所有的端点中,排除/actuator/beans这个端点
management.endpoints.web.exposure.exclude=beans
management.endpoints.web.exposure.include=*

# 如果要开启/actuator/shutdown,要额外再加这一行
management.endpoint.shutdown.enabled=true

3、路径映射(application.properties)

3.1、公共路径

  1. 默认情况下所有端点都暴露在"/actuator"路径下
  2. 通过修改application.properties来自定义路径映射
# 原本內建的/actuator/xxx路径,都会变成/manage/xxx,可以用來防止被其他人猜到
management.endpoints.web.base-path=/manage
 

3.2、特定路径

  1. 这里以/actuator/health作为案例
    1. 默认情况,健康检查暴露在"/actuator/health"路径下
  2. 通过修改application.properties来自定义路径映射
  
# 原本內建的/actuator/health路径, 会变成/actuator/healthcheck,可以用來防止被其他人猜到
management.endpoints.web.path-mapping.health=healthcheck

4、管理端口调整(application.properties)

# 指定端口,默认跟server.port一样,可以防止被其他人猜到
management.server.port=10111

5、端点响应缓存(application.properties)

对于一些不带参数的端点请求会自动进行缓存,我们可以通过如下方式配置缓存时间

# 下面配置表示 beans 端点的缓存时间为 100s 
management.endpoint.beans.cache.time-to-live=100s

6、设置访问的IP(application.properties)

# 设置为本地ip,防止远程访问该连接进行关闭服务
# 不允许远程管理连接,安全性考虑
management.server.address=127.0.0.1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值