springboot2.x下actuator模块
一、简介
spring-boot-starter-actuator模块是一个spring提供的监控模块。我们在开运行发过程中,需要实时和定时监控服务的各项状态和可用性。Spring Boot的spring-boot-starter-actuator 模块(健康监控)功能提供了很多监控所需的接口,可以对应用系统进行配置查看、相关功能统计等。
二、实现
在maven的pom中引入:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
如果使用HTTP调用的方式,还需要这个依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
spring:
application:
name: spring-cloud-consul-consumer
server:
port: management:
server:
port: 54001 #如果不配置,默认与服务端口一致
health:
db:
enabled: true
mail:
enabled: true
endpoint:
env:
enabled: true
endpoints:
web:
exposure:
include: "*"
访问:http://localhost:54001/health 这是springboot1.x的访问
springboot2.x 后 http://localhost:54001/actuator/health
结果:
2、info:配置
info:
app:
name: "@project.name@" #从pom.xml中获取
description: "@project.description@"
version: "@project.version@"
spring-boot-version: "@project.parent.version@"
访问:http://localhost:54001/actuator/info
{"app":{"name":"demo","description":"Demo project for Spring Boot","version":"0.0.1-SNAPSHOT","spring-boot-version":"2.1.0.RELEASE"}}
更多端点访问,可以访问:http://localhost:54001/actuator查看。
{"_links":{"self":{"href":"http://localhost:54001/actuator","templated":false}, "archaius":{"href":"http://localhost:54001/actuator/archaius","templated":false}, "auditevents":{"href":"http://localhost:54001/actuator/auditevents","templated":false}, "beans":{"href":"http://localhost:54001/actuator/beans","templated":false}, "caches-cache":{"href":"http://localhost:54001/actuator/caches/{cache}","templated":true}, "caches":{"href":"http://localhost:54001/actuator/caches","templated":false}, "health":{"href":"http://localhost:54001/actuator/health","templated":false}, "health-component":{"href":"http://localhost:54001/actuator/health/{component}","templated":true}, "health-component-instance":{"href":"http://localhost:54001/actuator/health/{component}/{instance}","templated":true}, "conditions":{"href":"http://localhost:54001/actuator/conditions","templated":false}, "configprops":{"href":"http://localhost:54001/actuator/configprops","templated":false},
"env":{"href":"http://localhost:54001/actuator/env","templated":false},
"env-toMatch":{"href":"http://localhost:54001/actuator/env/{toMatch}","templated":true}, "info":{"href":"http://localhost:54001/actuator/info","templated":false},
"loggers":{"href":"http://localhost:54001/actuator/loggers","templated":false}, "loggers-name":{"href":"http://localhost:54001/actuator/loggers/{name}","templated":true},
"heapdump":{"href":"http://localhost:54001/actuator/heapdump","templated":false}, "threaddump":{"href":"http://localhost:54001/actuator/threaddump","templated":false},
"metrics":{"href":"http://localhost:54001/actuator/metrics","templated":false}, "metrics-requiredMetricName":{"href":"http://localhost:54001/actuator/metrics/{requiredMetricName}","templated":true}, "scheduledtasks":{"href":"http://localhost:54001/actuator/scheduledtasks","templated":false},
"httptrace":{"href":"http://localhost:54001/actuator/httptrace","templated":false}, "mappings":{"href":"http://localhost:54001/actuator/mappings","templated":false}, "refresh":{"href":"http://localhost:54001/actuator/refresh","templated":false}, "features":{"href":"http://localhost:54001/actuator/features","templated":false}, "service-registry":{"href":"http://localhost:54001/actuator/service-registry","templated":false}, "consul":{"href":"http://localhost:54001/actuator/consul","templated":false}}}
更多详细内容参考:https://blog.csdn.net/Dreamhai/article/details/81077903
最新文章
- [转]C#反射,根据反射将数据库查询数据和实体类绑定,并未实体类赋值
- 防御CSRF的方法有哪些(一) HTTP 头中自定义属性并验证 CSRF跨站域请求伪造攻击
- 【日记】thinkphp项目阿里云ECS服务器部署
- Delphi又要换东家了
- nyoj 170 网络的可靠性
- [Introduction to programming in Java 笔记] 1.3.9 Factoring integers 素因子分解
- PuTTY &#39;modmul()&#39; 函数缓冲区下溢漏洞(CVE-2013-4206)
- 开始使用Logstash
- linux下tomcat shutdown后 java进程依然存在
- [js高手之路] 跟GhostWu一起封装一个字符串工具库-扩展字符串位置方法(4)
- 201521123091 《Java程序设计》第11周学习总结
- java动态绑定与静态绑定【转】
- (一)ORB描述子提取
- 2018-2019-2 网络对抗技术 20162329 Exp5 MSF基础应用
- 浅谈js中的this关键字
- isinstance,issubclass,内置函数__str__和__repr__,__format__,dir()函数
- Spring笔记 #01# 一个小而生动的IOC例子代码
- JVM的Client模式与Server模式
- keras后端设置【转载】
- Oracle 拼接字符串