Spring-boot Actuator (Monitoring) configuration and use

Source: Internet
Author: User

In a production environment, the availability of services needs to be monitored in real time or regularly. The Spring-boot Actuator (monitoring) feature provides many of the interfaces required for monitoring. The simple configuration and use are as follows:
1, the introduction of dependency:
[HTML] view plain copy <dependency> <groupId>org.springframework.boot</groupId> & Lt;artifactid>spring-boot-starter-actuator</artifactid> </dependency>
This dependency is also required if the HTTP call is used:
[HTML] view plain copy <dependency> <groupId>org.springframework.boot</groupId> & Lt;artifactid>spring-boot-starter-web</artifactid> </dependency>
2. Configuration:

The HTTP port specified in APPLICATION.YML (if not specified, uses the same port as the server); Specifies that a check is removed (such as not monitoring Health.mail):

[plain] view plain copy server:port:8082 management:port:54001 health:mail:en Abled:false

3. Use: View the health indicator: http://localhost:54001/health
[plain] view plain copy {"status": "Up", "diskspace": {' status ': ' Up ', ' total ': 120031539200, "free": 33554337792 , "Threshold": 10485760}, "db": {"status": "Up", "DataSource1": {"status": "Up", "Database": "MySQL", "Hello": 1}, " DataSource2 ": {" status ":" Up "," Database ":" MySQL "," Hello ": 1}}}
4. Custom indicators:
4.1/health: Implements the Healthindicator interface in a class, and then implement the health () method in it:

Code:

[Java]  View plain  copy @SpringBootApplication    @EnableScheduling    public class  MySpringBootApplication implements HealthIndicator{       private  static logger logger = loggerfactory.getlogger (Myspringbootapplication.class);               public static void main ( String[] args)  {           springapplication.run ( Myspringbootapplication.class, args);            Logger.info ("my spring boot application started");       }           /**       *  when the/health interface is called, Returns one more attribute: ' myspringbootapplication ': {' status ': ' Up ', ' Hello ': ' World '}       */    &NBSP;&NBSP;   @Override        public health health ()  {  

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.