spring - 如何在 Spring-Boot 中禁用指标?
问题描述
我使用 DropWizard 来收集我自己的端点指标。我喜欢我的解决方案,因为我可以根据需要添加自己的尺寸。
除了这个 Spring 自动收集并向 Dropwizard 添加我不需要的其他指标数据。如何禁用 Spring-Boot 中的指标以禁用此功能?
我找到了MetricsDropwizardAutoConfiguration.class
,DropwizardMetricServices.class
但似乎没有一个属性或配置可以关闭它们。
所以我的下一个想法是关闭 Spring-Boot-Actuator 的指标。我在调试时发现了这些 application.properties,但这些并没有关闭指标日志记录:
endpoints:
metrics:
enabled: false
management.endpoints.metrics.enabled: false
spring:
metrics:
export:
enabled: false
编辑
springBootVersion = '1.5.9.RELEASE'
解决方案
对于1.5.9
这些应该工作:
endpoints.enabled=false # Enable endpoints.
endpoints.actuator.enabled=false # Enable the endpoint.
这应该在 2.x 中工作:
在应用程序属性中:
management.endpoint.metrics.enabled=false
在 yaml 中:
management:
endpoint:
metrics:
enabled: false
推荐阅读
- reactjs - 如何使用 ReactJs 在没有 else 的情况下编写三元运算符?
- excel - 如何在 Range 方法的地址中使用变量
- local-storage - Office 加载项:存储在 localStorage 中的数据在 Excel 桌面 Office365 中的对话框中不可用
- list - Lisp 交换功能
- python - 需要正则表达式来替换双引号之外的所有逗号并替换为 | - 在蟒蛇
- typescript - 用 key 中的泛型类型来实现这一点的优雅方式
- javascript - 一个节点js项目的结构
- flutter - 试图在列表中获取数据,我收到一个错误:未定义命名参数
- python - 为每个 id 匹配正负数对
- typescript - 如何告诉打字稿给定的输入将具有预期类型的子集