SpringBoot初级开发--工程的指标监控spring-boot-starter-actuator(3)

  spring-boot-starter-actuator主要用于Springboot工程项目的健康指标数据的监控,接上面第2部分的内容,我们接入指标监控模块。

1.pom.xml文件增加相关依赖

    <!-- 应用监控检测 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

2.application.properties配置文件增加如下配置

#健康检查,从pom中获取工程名,描述,版本
info.application.name="@project.name@"
info.application.description="@project.description@"
info.application.version="@project.version@"
#指定访问端口
management.server.port=52001
#启动所有监控点
management.endpoints.web.exposure.include=*
#info默认是关闭的,需要打开
management.info.env.enabled=true
#/actuator/xxx路徑,都变成/manage/xxx
#management.endpoints.web.base-path=/manage

配置好以上配置,启动springboot应用。通过浏览器可以访问http://localhost:52001/actuator/health,http://localhost:52001/actuator/info。得到如下结果

在这里插入图片描述

在这里插入图片描述
涉及到的常用监控内容反馈有这些
GET /actuator 查看有哪些 Actuator endpoint 是开放的,和对应的路径
GET /actuator/beans 查看容器中的 bean
GET /actuator/health 查看当前应用指标情况,实现HealthIndicator可以自定义指标项
GET /actuator/loggers 查看当前应用日志级别情况,可以运行时调整
GET /actuator/info 应用信息展示
GET /actuator/threaddump 当前应用线程栈dump,同 jstack

应用程序的范例在这里下载 链接: https://pan.baidu.com/s/1i1z3FbWVobXxyyiiE_oTYQ 提取码: 2yc3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

机核动力

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值