当前位置: 首页 > news >正文

SpringBoot的actuator组件快速使用

       Spring Boot Actuator 组件的主要作用是为 Spring Boot 应用提供生产级监控和管理功能。它让应用能够自我监控和管理,是微服务架构中不可或缺的组件。

  1.引入依赖

      <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>

  2.application.xml文件配置

management:endpoint:web:exposure:include: "*"health:show-details: alwayshealth:defaults:enabled: false
      上面配置会暴露所有端点,并总是显示健康检查详情,禁用默认的健康检查器(其它端点访问结果为空)。

3.主要端点以及作用

端点路径作用
health/actuator/health应用健康状态
info/actuator/info应用基本信息
metrics/actuator/metrics应用指标数据
env/actuator/env环境配置信息
configprops/actuator/configprops配置属性
beans/actuator/beansSpring Beans 信息
mappings/actuator/mappingsURL 映射信息
loggers/actuator/loggers日志配置管理
threaddump/actuator/threaddump线程转储
heapdump/actuator/heapdump堆内存转储

4.访问端点/actuator/health

启动服务之后。
{"status": "UP","details": {"application": {"status": "UP"}}
}

当启用默认健康检查器时

management:endpoint:web:exposure:include: "*"health:show-details: alwayshealth:defaults:enabled: true

显示信息如下:

{"status": "DOWN","details": {"diskSpace": {"status": "UP","details": {"total": 350731890688,"free": 312695111680,"threshold": 10485760}},"db": {"status": "UP","details": {"database": "MySQL","hello": 1}},"refreshScope": {"status": "UP"},"redis": {"status": "DOWN","details": {"error": "org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379"}}}
}

5./actuator(显示所有端点的页面)

{"_links": {"self": {"href": "http://localhost:8080/lams-portal/actuator","templated": false},"health": {"href": "http://localhost:8080/lams-portal/actuator/health","templated": false},"health-component-instance": {"href": "http://localhost:8080/lams-portal/actuator/health/{component}/{instance}","templated": true},"health-component": {"href": "http://localhost:8080/lams-portal/actuator/health/{component}","templated": true},"info": {"href": "http://localhost:8080/lams-portal/actuator/info","templated": false}}
}

6.访问其它端点显示为空(没有配置)

http://www.dtcms.com/a/508028.html

相关文章:

  • STM32学习(MCU控制)(GPIO)
  • wordpress站点标题添加如何注册一个自己的公司
  • 台州企业网站搭建价格网站开发的交付文档
  • 橙色守护者:嘉顺达蓝海的危险品运输安全密码
  • 安全监控摄像头通过智能组网模块实现联网报警和远程管理的实践解析
  • AI时代的数据管理新范式:Git for Data让数据工程化
  • Linux中内核调用用户空间程序的实现
  • 建网站空间的详细说明网站备案怎么查询
  • 2025 兽用 mRNA 疫苗市场调研:58.7% CAGR 下,技术路线与投资前景深度分析
  • 关于 Qt5.x版本离线安装可以跳过登录但是实际离线仍需要登录 的解决方法
  • 什么时候会出现电源平面谐振?
  • php做网站常见实例新市网站建设
  • 【Vue知识点总结】style标签的 scoped 属性
  • 网站移动适配怎么做济南做网站互联网公司排名
  • authui!CLogonFrame::Create中的USER32!LoadImageW可以作为有效起始断点
  • Linux服务器编程实践50-TCP接收与发送缓冲区:SO_RCVBUF与SO_SNDBUF设置
  • 免费无版权图片素材网站中国制造网简介
  • 鸿蒙Next Test Kit:一站式自动化测试框架详解
  • 《微信小程序》第一章:开发前准备与配置
  • 实验二-决策树-葡萄酒
  • 用双语网站做seo会不会建设一个网站需要哪些员工
  • 专项智能练习(教学过程的规律)
  • 设计模式-创建型设计模式
  • 非关系型数据库(NoSQL)学习指南:从入门到实战
  • Endnote | word中参考文献段落对齐及悬挂缩进的设置
  • MCU硬件学习
  • SpringBoot教程(十九) | SpringBoot集成Slf4j日志门面(优化版)
  • 帮别人备案网站大连企业网站建设模板
  • 关于反向传播
  • --- 数据结构 AVL树 ---