Use Spring-boot-admin to monitor Spring-boot services _spring

Source: Internet
Author: User
Spring-boot-admin, referred to as SBA, is a monitoring tool for UI landscaping packages for Spring-boot actuator interfaces. He can: In the list of all monitored spring-boot items of basic information, detailed health information, memory information, JVM information, garbage collection information, various configuration information (such as data source, cache list and hit Ratio), can also directly modify the level of logger. Official website: https://github.com/codecentric/spring-boot-admin Use guide: http://codecentric.github.io/spring-boot-admin/1.5.0/
In a few simple steps, you can configure and use the SBA (divided into the monitoring side and the monitored end): 1, create the project (slightly) 2, introduce the dependency:
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId> spring-boot-admin-server</artifactid>
			<version>1.5.0</version>
		</dependency>
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId> spring-boot-admin-server-ui</artifactid>
			<version>1.5.0</version>
		</dependency >

3, configuration file (application.yml) configuration (optional):
Spring:
  application:
    name:svc-monitor
  Boot:
    admin:
      context-path:/SBA    # Configuration Access path is: http:// LOCALHOST:64000/SVC-MONITOR/SBA
server:
  port:64000
  context-path:/svc-monitor/#统一为访问的url加上一个前缀
The above configuration is intended to specify a particular access path. If this is not configured, the access path is: http://localhost:64000
4. Activate SBA using @enableadminserver annotation:
@SpringBootApplication
@EnableScheduling
@EnableAdminServer public
class Svcmonitorapplication { Public
	static void Main (string[] args) {
		springapplication.run (svcmonitorapplication.class, args);
}

By the monitoring side (Spring-boot project) to the monitoring side register themselves: 1, add dependencies:
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId> spring-boot-admin-starter-client</artifactid>
			<version>1.5.0</version>
		</ Dependency>

2. Configuration file (application.yml) configuration:
Spring:
  Boot:
    admin:
      client:
        prefer-ip:true # Troubleshoot host name problems when running under Windows
      url:http://localhost : 64000/svc-monitor # addresses registered to the server
management:
  port:64001 security
  :
    Enabled:false # Spring-boot After 1.5.2 enforces security policy strictly, you need to configure this to False
info: #定义各种额外的详情给服务端显示
  app:
    name: "@project. name@" #从pom. xml
    Description: "@project. description@"
    version: "@project. version@"
    spring-boot-version: "@ project.parent.version@ "

3, other configuration: If you need to display the project version number, you need to add this (Build-info) in the Pom.xml:
<build>
    <plugins>
        <plugin>
            <groupid>org.springframework.boot</groupid >
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                < execution>
                    <goals>
                        <goal>build-info</goal>
                    </goals>
                </execution >
            </executions>
        </plugin>
    </plugins>
</build>

4, Problem solving: if detected by the monitoring side of the launch of the Inetaddress.getlocalhost () throws unknownhostexception error, because the machine name and IP is not configured with the corresponding relationship. Workaround: Edit Hosts file: Vi/etc/hosts add IP and Machine Name association: 192.168.0.31 HOST31 myhost-31
After the monitor and the monitored end are started, visit: HTTP://LOCALHOST:64000/SVC-MONITOR/SBA, you can see the various details of the monitored service.
The above is the active registration method of the monitored end.
There is another way to do this: if the monitor has already used spring Cloud to register the service to Eureka, it can be detected and monitored directly by the monitoring side to Euraka. This method debugging is more complex, here is not introduced.

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.