Spring boot Actuator 简单学习

官方文档:  Spring Boot Reference Documentation

Spring Boot包括了很多额外的特性来帮助我们监控和管理我们的应用.我们可以选择Http终端或者JMX

方式:

  • HTTP
  • JMX

引入依赖

    1

    2

    3

    4

    5

    6

<dependencies>

    <dependency>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-actuator</artifactId>

    </dependency>

</dependencies>

命名由来

 Actuator是一个制造业术语,指的是移动或者控制某物的机械装置.Actuator可以产生巨大的运动通过很小的变化.

Endpoint

Endpoint可以监控并且和我们的应用进行交互

id

描述

默认JMX

默认HTTP

默认开启

auditevents

Exposes audit events information for the current application. Requires an AuditEventRepository bean.

Yes

No

beans

Displays a complete list of all the Spring beans in your application.

Yes

No

Y

caches

Exposes available caches.

Yes

No

Y

conditions

Shows the conditions that were evaluated on configuration and auto-configuration classes and the reasons why they did or did not match.

Yes

No

Y

configprops

Displays a collated list of all @ConfigurationProperties.

Yes

No

Y

env

Exposes properties from Spring’s ConfigurableEnvironment.

Yes

No

Y

flyway

Shows any Flyway database migrations that have been applied. Requires one or more Flyway beans.

Yes

No

health

Shows application health information.

Yes

Yes

Y

httptrace

Displays HTTP trace information (by default, the last 100 HTTP request-response exchanges). Requires an HttpTraceRepository bean.

Yes

No

Y

info

Displays arbitrary application info.

Yes

No

Y

integrationgraph

Shows the Spring Integration graph. Requires a dependency on spring-integration-core.

Yes

No

loggers

Shows and modifies the configuration of loggers in the application.

Yes

No

Y

liquibase

Shows any Liquibase database migrations that have been applied. Requires one or more Liquibase beans.

Yes

No

metrics

Shows “metrics” information for the current application.

Yes

No

Y

mappings

Displays a collated list of all @RequestMapping paths.

Yes

No

Y

quartz

Shows information about Quartz Scheduler jobs.

Yes

No

Y

scheduledtasks

Displays the scheduled tasks in your application.

Yes

No

Y

sessions

Allows retrieval and deletion of user sessions from a Spring Session-backed session store. Requires a servlet-based web application that uses Spring Session.

Yes

No

shutdown

Lets the application be gracefully shutdown. Disabled by default.

Yes

No

N

startup

Shows the startup steps data collected by the ApplicationStartup. Requires the SpringApplication to be configured with a BufferingApplicationStartup.

Yes

No

threaddump

Performs a thread dump.

Yes

No

Y

下面的是web应用的endpoint

id

描述

默认JMX

默认HTTP

默认开启

heapdump

Returns a heap dump file. On a HotSpot JVM, an HPROF-format file is returned. On an OpenJ9 JVM, a PHD-format file is returned.

N/A

No

Y

jolokia

Exposes JMX beans over HTTP when Jolokia is on the classpath (not available for WebFlux). Requires a dependency on jolokia-core.

N/A

No

logfile

Returns the contents of the logfile (if the logging.file.name or the logging.file.path property has been set). Supports the use of the HTTP Range header to retrieve part of the log file’s content.

N/A

No

prometheus

Exposes metrics in a format that can be scraped by a Prometheus server. Requires a dependency on micrometer-registry-prometheus.

N/A

No

Y

使用Actuator

HTTP 访问

   /actuator/<id>

端⼝与路径

    management.server.address=

    management.server.port=

    management.endpoints.web.base-path=/actuator

    management.endpoints.web.path-mapping.<id>=路径

开启 Endpoint

    management.endpoint.<id>.enabled=true

    management.endpoints.enabled-by-default=false

暴露 Endpoint

    management.endpoints.jmx.exposure.exclude=

    management.endpoints.jmx.exposure.include=*

    management.endpoints.web.exposure.exclude=

    management.endpoints.web.exposure.include=info, health

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

FantasyBaby

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

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

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

打赏作者

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

抵扣说明:

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

余额充值