使用SpringBoot Actuator监控应用
2017-04-23 00:00
1126 查看
摘要: 原创出处 http://peijie2016.oschina.io 欢迎转载,保留摘要,谢谢!
Actuator是Spring Boot提供的对应用系统的自省和监控的集成功能,可以对应用系统进行配置查看、相关功能统计等。
endpoints.mappings.sensitive=false
这样需要对每一个都设置,比较麻烦。敏感方法默认是需要用户拥有
management.security.enabled=false
或者配合
此时访问localhost:8080/info返回一下信息
如果使用
// 获取pom.xml中project节点下artifactId属性
artifact: "@project.artifactId@"
这个操作比较敏感,要想真正生效,需要以下配置:
endpoints.shutdown.enabled: true
我们可以通过实现
查看详细介绍,请移步 官方文档
Actuator是Spring Boot提供的对应用系统的自省和监控的集成功能,可以对应用系统进行配置查看、相关功能统计等。
使用Actuator
引入依赖即可Maven:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
Gradle:
compile('org.springframework.boot:spring-boot-starter-actuator')
Endpoints
列举一些主要的endpoints配置文件属性介绍
地址和端口的配置
management.port:指定访问这些监控方法的端口,与逻辑接口端口分离。如果不想将这些暴露在http中,可以设置 management.port = -1
management.address:指定地址,比如只能通过本机监控,可以设置 management.address = 127.0.0.1
敏感信息访问限制
根据上面表格,鉴权为false的,表示不敏感,可以随意访问,否则就是做了一些保护,不能随意访问。
endpoints.mappings.sensitive=false
这样需要对每一个都设置,比较麻烦。敏感方法默认是需要用户拥有
ACTUATOR角色,因此,也可以设置关闭安全限制:
management.security.enabled=false
或者配合
Spring Security做细粒度控制。
自定义系统信息
可以通过访问/info获取信息,需要在配置文件设置
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返回一下信息
如果使用
maven,可以访问pom.xml文件的信息,用法如下:
// 获取pom.xml中project节点下artifactId属性
artifact: "@project.artifactId@"
其他
/shutdown这个需要post方式,通过请求来关闭应用。
这个操作比较敏感,要想真正生效,需要以下配置:
endpoints.shutdown.enabled: true
我们可以通过实现
HealthIndicator接口,编写自己的
/health方法逻辑。也可以增加自定义监控方法。
查看详细介绍,请移步 官方文档
相关文章推荐
- 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- springboot(十九)使用actuator监控应用
- 使用Spring Boot Actuator监控应用
- Spring Boot教程(十三)在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- springboot 使用Spring Boot Actuator监控应用小结
- springboot(十九):使用Spring Boot Actuator监控应用
- springboot(十九):使用Spring Boot Actuator监控应用
- 使用SpringBoot Actuator监控应用示例
- 在传统Spring应用中使用spring-boot-actuator模块提供监控端点
- Spring Boot 构建应用——使用 Actuator 监控端点
- 使用Spirng Boot Admin监控Spring Cloud应用项目
- spring-boot 之 使用Admin监控应用
- Spring boot Actuator监控的使用
- Spring Boot参考教程(三)内部应用监控(Actuator)
- springBoot整合actuator监控配置和使用
- spring-boot-starter-actuator(健康监控)配置和使用
- (17)spring boot的Actuator监控使用
- spring boot starter actuator(健康监控)配置和使用教程
- spring-boot 之 使用Admin监控应用