Spring Boot Uncover and Combat (ix) Application monitoring-HTTP application monitoring

Source: Internet
Author: User

Article Directory

  1. 1. Quick Start
  2. 2. Monitor and manage endpoint 3. Customizing Endpoints
    1. 2.1. Health usage Indicators
    2. 2.2. Info View app Information
    3. 2.3. Metrics application Basic indicators
    4. 2.4. Trace Basic HTTP trace Information
    5. 2.5. shutdown close the current app
  3. 4. Source Code

Spring Boot provides runtime application monitoring and management capabilities. In this paper, we monitor and manage the application through HTTP.

Quick Start

Spring Boot monitoring Core is spring-boot-starter-actuator dependency, after increasing the dependency, spring boot will default to configure some common monitoring, such as JVM monitoring, class loading, health monitoring and so on.

    1. <dependency>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactId>spring-boot-starter-actuator</artifactId>
    4. </dependency>

If you use HTTP calls, you also need to spring-boot-starter-web dependencies.

    1. <dependency>
    2. <groupId>org.springframework.boot</groupId>
    3. <artifactId>spring-boot-starter-web</artifactId>
    4. </dependency>
monitoring and managing endpoints

The current supported monitoring is listed in the latest Spring Boot version 1.4.3.

http Method Path Description
GET /actuator See a list of all endpoint and need to join Spring HATEOAS support
GET /autoconfig View the usage of automatic configuration for an app
GET /beans View information about all the beans that are applied
GET /configprops View all configuration properties for an app
GET /dump To view thread state information for an app
GET /env View all environment information for an app
GET /flyway View migration Routes Database migrations
GET /health View App Health Metrics
GET /info View app Information
GET /liquibase View an already Liquibase database migration app
GET /mappings View all URL mappings
GET /metrics View App Basic Metrics
POST /shutdown Allows graceful closing of the current app (not enabled by default)
GET /trace To view basic HTTP trace Information
GET /docs To view documents, you need to rely on Spring-boot-actuator-docs
GET /heapdump Returns an gzip compressed hprof heap dump file
GET /jolokia Exposing JMX beans (when Jolokia path)
GET /LogFile View the contents of the log file (if the Logging.file or Logging.path property is set). Supports the use of portions of the HTTP range header to log files to recover content.
Health usage Indicators

We can pass the Http://localhost:8080/health, statistical system status, the default inside currently only system conditions and disk status. These detectors are implemented through the Healthindicator interface, and in the next article I will explain the custom health detection through the Healthindicator interface.

Info View app Information

By default, only an empty JSON content is returned. We can set some properties through the info prefix in the application.properties configuration file.

    1. Info. Author. Realname= Liang
    2. Info. Author. Nickname=lianggzone

We can also set some properties in the Application.yml configuration file.

    1. Info. Author:
    2. Email: [email protected]. COM
    3. Blog: http://blog.720ui.com
Metrics application Basic indicators

We can get all kinds of important metrics of current application through http://localhost:8080/metrics, such as: memory information, thread information, garbage collection information, etc.

We can also get more granular metrics through the/metrics/{name} interface, such as we can access the/metrics/mem.free to get the current amount of available memory.

Trace Basic HTTP trace Information

View basic HTTP trace information. By default, the storage of tracking information takes the form of memory implemented by Org.springframework.boot.actuate.trace.InMemoryTraceRepository and always retains the last 100 request records.

shutdown close the current app

The shutdown endpoint is not enabled by default and we can open it in application.properties. In addition, the shutdown endpoint does not support GET requests and we need to access them via the POST method.

    1. Endpoints. Shutdown. Enabled=true
Customizing Endpoints

Endpoints can be customized in the Spring Boot configuration file. For example, above, we open the shutdown endpoint.

    1. Endpoints. Shutdown. Enabled=true

The prefix for the endpoint is, Endpoints + "." + END name.

The default endpoint access path is the root directory, which we can customize by modifying the configuration.

    1. Management. Context-path=/manage

At this point, our access address becomes: Http://localhost:8080/manage/info

In addition, the default monitoring interface port is consistent with the port of the business, and we can change the access port of the endpoint for security reasons.

    1. Management. Port=9090

We can even close the HTTP endpoint.

    1. Management. Port=-1
Source Code

Related example complete code: springboot-action

Finish



If you feel that my article is helpful to you, please feel free to make a reward.

    • Copyright NOTICE: This article was published by Liang in Liang Blog
    • Reprint statement: Free reprint-Non-commercial-non-derivative-maintain attribution (Creative Sharing 3.0 license), non-commercial reprint please indicate the author and source, commercial reprint please contact the author himself.
    • Article title: Spring Boot Secrets and Combat (ix) Application monitoring-HTTP application monitoring
    • Article Link: http://blog.720ui.com/2017/springboot_09_actuator_http/

Spring Boot Uncover and Combat (ix) Application monitoring-HTTP application monitoring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.