Spring Boot operational status monitoring Actuator

The Actuator Spring Boot provides the capability to monitor the operational status of the monitoring data Actuator can be obtained by REST , remote shell (version 1.5 later abandoned) and JMXin the way. We first introduced by the view node Actuator REST ways, this is the most common and simple method.

In the project's pomintroduction Actuator file starting rely on the Spring-the Boot-Starter-Actuator , the code list is as follows:

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

In the configuration file application.ymlconfiguration management.portand management.security.enabled, equipped with two separate configurations Actuator exposure of foreign REST APInon-secure authentication port number of the interface and Actuator taken its code list is as follows:

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: always
    shutdown:
      enabled: true
  server:
    port: 9001

In the above configuration code specified in the Actuator exposed outside REST APIthe port number of the interface as 9001, if not specified, the port is the port to start the application, purpose of this program is to separate monitoring ports and port procedures. Configuration management.endpoints.web.exposure.includeis set to "*" all nodes exposed Actuator assembly; configuration management.endpoint.shutdownis set to "to true", open and can be closed by the request function. Start project, in the console you can see the following information:

[Pictures of foreign chains dump fails, the source station may have a security chain mechanism, it is recommended to save the picture down directly upload (img-aznyA0zr-1582192408624) (C: \ Users \ DuXiaobo \ AppData \ Roaming \ Typora \ typora-user-images \ 1580874829607.png)]

From the above information, Actuator Spring Boot monitor port is 9001.

Actuator Spring Boot key features is to provide a large number of nodes in the Web application, the real-time understanding of application health through these nodes. With Actuator, you can know Bean in Spring application contexts is how to assemble together, and you can get a measure of information and runtime environment properties and so on.

Actuator port information
Types of API port description
GET /autoconfig The endpoint used to obtain configuration report automation applications, including automated configuration of all the candidates. It also lists the prerequisites for automated configuration of each candidate meets. Therefore, the endpoint can help us to easily find the specific reasons why some automated configuration no effect. The contents of the report will automate the configuration is divided into two parts:
  • positiveMatches returned automated matching conditions for a successful configuration
  • negativeMatches is a condition in return match with unsuccessful automation
GET /configprops Description configuration properties (default values)
  • The prefix attribute represents a configuration prefix property
  • properties represent the name and value of that property
GET /beans Description of the application in the context of all of the Bean, as well as their relationship
  • bean: Bean name
  • scope: Bean scopes
  • type: Bean Java type
  • Specific path class file: reource
  • dependencies: dependent Bean name
GET /threaddump Take a snapshot of the thread activity
GET /env Gets all the available application environment property report. Comprising: a variable environment, the JVM properties, configuration of the application configuration, the command line parameters
GET /env/{name} Attribute value to obtain the specific environment under the name
/ env interface can also be used to obtain the value of a single attribute, only when the request / env can add attribute name
GET /sessions User Session
GET /health Application of health indicators
GET /info This endpoint information is used to return some custom applications. By default, the endpoint will return an empty json content
we can set some properties by info prefix application.properties profile
GET /auditevents Displays the current audit events in the application of information
GET /conditions Status display configuration and autoconfiguration classes classes, and why they are applied or not applied
GET /flyway Display Database migration path
GET /liquibase Liquibase show any data migration path (if present)
GET /loggers Display and set the Logger level
GET /mappings Description of all of the URI path, and they and the controller (included Actuator endpoints) set out the mapping between the application interfaces all released
  • bean attribute identifies the mapping relationship of the requesting processor
  • The method attribute identifies the class specific processing and handling functions of the mapping relationship
GET /metrics Metric information reporting various applications, such as memory usage, HTTP request count, thread information, garbage collection information
  • System information: number of processors including processors, operating time and uptime instance.uptime, the system load average systemload.average
  • mem *:. Memory summary information, including the total amount of memory allocated to the application and the amount of memory currently free. This information comes from java.lang.Runtime
  • heap *:. heap memory usage. java.lang.management.MemoryUsage java.lang.management.MemoryMXBean interface information from the acquired method getHeapMemoryUsage
  • nonheap *:. Non-heap memory usage. java.lang.management.MemoryUsage java.lang.management.MemoryMXBean interface information from the acquired method getNonHeapMemoryUsage
  • threads *:. thread usage, including the number of threads, the number of guard (daemon), threads peak (peak), and these data are from java.lang.management.ThreadMXBean
  • classes *:. application loading and unloading of class statistics. These data are from java.lang.management.ClassLoadingMXBean
  • gc.*:垃圾收集器的详细信息,包括垃圾回收次数gc.ps_scavenge.count、垃圾回收消耗时间gc.ps_scavenge.time、标记-清除算法的次数gc.ps_marksweep.count、标记-清除算法的消耗时间gc.ps_marksweep.time。这些数据均来自java.lang.management.GarbageCollectorMXBean
  • httpsessions.*:Tomcat容器的会话使用情况。包括最大会话数httpsessions.max和活跃会话数httpsessions.active。该度量指标信息仅在引入了嵌入式Tomcat作为应用容器的时候才会提供
  • gauge.*:HTTP请求的性能指标之一,它主要用来反映一个绝对数值。比如上面示例中的gauge.response.hello: 5,它表示上一次hello请求的延迟时间为5毫秒
  • counter.*:HTTP请求的性能指标之一,它主要作为计数器来使用,记录了增加量和减少量。如上示例中counter.status.200.hello: 11,它代表了hello请求返回200状态的次数为11
对于gauge.*和counter.*的统计,这里有一个特殊的内容请求star-star,它代表了对静态资源的访问。
GET /scheduledtasks 显示应用程序中的计划任务
GET /httptrace 提供基本的HTTP请求跟踪信息(时间戳、HTTP头等)。
默认情况下,跟踪信息的存储采用org.springframework.boot.actuate.trace.InMemoryTraceRepository实现的内存方式,始终保留最近的100条请求记录
GET /caches 暴露可用缓存
POST /shutdown 关闭应用程序,需要将management.endpoint.shutdown设置为true
发布了3 篇原创文章 · 获赞 0 · 访问量 19

Guess you like

Origin blog.csdn.net/weixin_42466157/article/details/104414930