Spring boot actuator端点启用和暴露操作

网友投稿 1119 2022-12-25

Spring boot actuator端点启用和暴露操作

Spring boot actuator端点启用和暴露操作

启用端点

默认情况下,除了shutdown端点是关闭的,其它的都是启用的。配置一个端点的启用,使用management.endpoint…enabled属性

下面的例子是启用shutdown端点:

management.endpoint.shutdown.enabled=true

如果你个人更喜欢自定义端点的启用和关闭,可以使用如下属性

management.endpoints.enabled-by-default=false

上面这个属性将关闭所有端点启用情况,自己可以单独的通过设置enabled属性启用端点;

下面的示例示关闭所有的端点,并且启用info端点:

management.endpoints.enabled-by-default = false

management.endpoint.info.enabled = true

禁用端点会被从ApplicationContext上下文中删除,如果只是想从技术上更改端点的暴露,可以使用include和exclude属性替代。

公开端点

由于端点可能包含敏感信息,应该仔细的考虑什么时候暴露它们,

下面的表格展示了内置端点的暴露情况:

ID

JMX

Web

auditevents

没有

beans

没有

caches

没有

conditions

没有

configprops

没有

env

没有

flyway

没有

health

heapdump

N / A

没有

httptrace

没有

info

integrationgraph

没有

jolokia

N / A

没有

logfile

N / A

没有

loggers

没有

liquibase

没有

metrics

没有

mappings

没有

prometheus

N / A

没有

scheduledtasks

没有

sessions

没有

shutdown

没有

threaddump

没有

要更改端点暴露,使用下面的特定技术include和 exclude特性:

属性

默认

management.endpoints.jmx.exposure.exclude

management.endpoints.jmx.exposure.include

*

management.endpoints.web.exposure.exclude

management.endpoints.web.exposure.include

info, health

include属性列出暴露端点的ID,exclude属性列出不应该暴露端点的ID;exclude属性的优先级高于include属性,include和exclude属性都可以使用端点列表来配置ID。

例如

要停止通过JMX公开所有端点并仅显示端点health和 info端点,请使用以下属性:

management.endpoints.jmx.exposure.include=health,info

*可用于选择所有端点。例如,要通过HTTP公开除了env和beans端点之外的所有内容,请使用以下属性:

management.endpoints.web.exposure.include=*

management.endpoints.web.exposure.exclude=env,beans

在YAML中有特殊的含义,所以如果想使用include或者exclude包含所有的端点时要加上双引号,如下示例:

management:

endpoints:

web:

exposure:

include: "*"

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:基于SpringBoot应用监控Actuator安全隐患及解决方式
下一篇:SpringBoot2新特性 自定义端点详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~