使用SpringBoot Actuator监控应用示例
Actuator是Spring Boot提供的对应用系统的自省和监控的集成功能,可以对应用系统进行配置查看、相关功能统计等。 使用Actuator 引入依赖即可
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
compile('org.springframework.boot:spring-boot-starter-actuator') Endpoints 列举一些主要的endpoints 配置文件属性介绍 地址和端口的配置
敏感信息访问限制 根据上面表格,鉴权为 endpoints.mappings.sensitive=false 这样需要对每一个都设置,比较麻烦。敏感方法默认是需要用户拥有 management.security.enabled=false 或者配合 自定义系统信息 可以通过访问 info: aaa: name: xxx email: xxx@qq.com bbb: age: 25 hobbies: running build: artifact: "@project.artifactId@" name: "@project.name@" version: "@project.version@" 此时访问 localhost:8080/info 返回一下信息 如果使用 // 获取pom.xml中project节点下artifactId属性 artifact: "@project.artifactId@" 其他 /shutdown这个需要post方式,通过请求来关闭应用。 这个操作比较敏感,要想真正生效,需要以下配置: endpoints.shutdown.enabled: true 我们可以通过实现HealthIndicator接口,编写自己的/health方法逻辑。也可以增加自定义监控方法。 查看详细介绍,请移步官方文档 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程小技巧。 您可能感兴趣的文章:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |