您的位置:首页技术文章
文章详情页

Spring Boot Actuator监控器配置及使用解析

浏览:4日期:2023-08-27 16:27:10

一、简介

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/beansmanagement: server: port: 9999 #设置Actuator监控端口 endpoints: web: exposure: include: ’*’ #打开Actuator所有监控 #exclude: [’env’,’beans’] base-path: /actuator #设置Actuator监控基本路径 #-----------------------------------INFO------------------------------------#自定义INFO信息#浏览器访问 http://localhost:9999/actuator/infoinfo: company: name: ’公司名称’ url: ’www.xxxx’ addr: ’china’

四、访问测试

1、beans终端

http://localhost:9999/actuator/beans

Spring Boot Actuator监控器配置及使用解析

2、env

http://localhost:9999/actuator/env

Spring Boot Actuator监控器配置及使用解析

3、自定义信息

Spring Boot Actuator监控器配置及使用解析

五、常用的监控终端

在百度搜索“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头等)

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持好吧啦网。

标签: Spring
相关文章: