Spring Boot Actuator监控器配置及使用解析
时间:2021-09-17 09:38:46|栏目:JAVA代码|点击: 次
一、简介
Actuator(激励者;执行器)是Spring Boot提供的一个可挺拔模块,用于对工程进行监控。其通过不同的监控终端实现不同的监控功能。其功能与Dubbo的监控中心类似,不同的是,Dubbo的监控中心是需要专门部署的,而Spring Boot的Actuator是存在于每一个工程中的。
二、依赖
随便一个Spring Boot工程中都可以使用Actuator对其进行监控。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
三、配置
#-----------------------------------Actuator监控器------------------------------------
# Actuator监控端口与控制中心,默认只开启info、与health监控
# http://localhost:9999/actuator/beans
management:
server:
port: 9999 #设置Actuator监控端口
endpoints:
web:
exposure:
include: '*' #打开Actuator所有监控
#exclude: ['env','beans']
base-path: /actuator #设置Actuator监控基本路径
#-----------------------------------INFO------------------------------------
#自定义INFO信息
#浏览器访问 http://localhost:9999/actuator/info
info:
company:
name: '公司名称'
url: 'www.xxxx'
addr: 'china'
四、访问测试
1、beans终端
http://localhost:9999/actuator/beans

2、env
http://localhost:9999/actuator/env

3、自定义信息

五、常用的监控终端
在百度搜索“springboot actuator”即可找到如下表格
| HTTP 方法 | 监控终端 | 功能描述 |
| GET | /autoconfig | 提供了一份自动配置报告,记录哪些自动配置条件通过了,哪些没通过 |
| GET | /configprops | 描述配置属性(包含默认值)如何注入Bean |
| GET | /beans | 描述应用程序上下文里全部的Bean,以及它们的关系 |
| GET | /dump | 获取线程活动的快照 |
| GET | /env | 获取全部环境属性 |
| GET | /env/{name} | 根据名称获取特定的环境属性值 |
| GET | /health | 报告应用程序的健康指标,这些值由HealthIndicator的实现类提供 |
| GET | /info | 获取应用程序的定制信息,这些信息由info打头的属性提供 |
| GET | /mappings | 描述全部的URI路径,以及它们和控制器(包含Actuator端点)的映射关系 |
| GET | /metrics | 报告各种应用程序度量信息,比如内存用量和HTTP请求计数 |
| GET | /metrics/{name} | 报告指定名称的应用程序度量值 |
| POST | /shutdown | 关闭应用程序,要求endpoints.shutdown.enabled设置为true |
| GET | /trace | 提供基本的HTTP请求跟踪信息(时间戳、HTTP头等) |
上一篇:基于hibernate框架在eclipse下的配置方法(必看篇)
栏 目:JAVA代码
本文标题:Spring Boot Actuator监控器配置及使用解析
本文地址:http://www.codeinn.net/misctech/175587.html


阅读排行
- 1Java Swing组件BoxLayout布局用法示例
- 2java中-jar 与nohup的对比
- 3Java邮件发送程序(可以同时发给多个地址、可以带附件)
- 4Caused by: java.lang.ClassNotFoundException: org.objectweb.asm.Type异常
- 5Java中自定义异常详解及实例代码
- 6深入理解Java中的克隆
- 7java读取excel文件的两种方法
- 8解析SpringSecurity+JWT认证流程实现
- 9spring boot里增加表单验证hibernate-validator并在freemarker模板里显示错误信息(推荐)
- 10深入解析java虚拟机




