使用spring boot admin监控spring cloud应用程序
2017-11-14 18:05
1411 查看
最近在找一个spring cloud的监控组件,要求粒度要到每一个接口的,hystrix dashboard显然不适合,也不是这个应用场景。后来发现了spring boot admin这个神器,可以注册到Eureka和spring cloud无缝整合,页面AngularJS写的还算凑合,里面包含有许多功能:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
好了,不多说,直接上和eureka整合的代码,它可以通过eureka注册表里面的信息来对每一个服务进行监控。
1、构建service-admin工程,pom如下:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
2、启动主类:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
3、配置文件application.properties:
2
3
4
5
4、logback.xml(实现日志级别修改功能):
2
3
4
5、启动:
6、注意:
如果要监控注册到eureka的服务,必须要在这个服务里面引入:
2
3
4
来开启一些管理功能,且须在配置文件加入一句:
关闭安全验证。
代码托管:https://github.com/Lovnx/micro-service
显示 name/id 和版本号 显示在线状态 Logging日志级别管理 JMX beans管理 Threads会话和线程管理 Trace应用请求跟踪 应用运行参数信息,如: Java 系统属性 Java 环境变量属性 内存信息 Spring 环境属性1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
好了,不多说,直接上和eureka整合的代码,它可以通过eureka注册表里面的信息来对每一个服务进行监控。
1、构建service-admin工程,pom如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.lovnx</groupId> <artifactId>micro-service</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> <artifactId>service-admin</artifactId> <packaging>jar</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.7</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server</artifactId> <version>1.4.6</version> </dependency> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-server-ui</artifactId> <version>1.4.6</version> </dependency> <dependency> <groupId>org.jolokia</groupId> <artifactId>jolokia-core</artifactId> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Camden.SR5</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
2、启动主类:
package com.lovnx; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.Configuration; import de.codecentric.boot.admin.config.EnableAdminServer; @Configuration @EnableAutoConfiguration @EnableDiscoveryClient @EnableAdminServer public class SpringBootAdminApplication { public static void main(String[] args) { SpringApplication.run(SpringBootAdminApplication.class, args); } }1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
3、配置文件application.properties:
server.port=7088 spring.application.name=service-admin eureka.client.serviceUrl.defaultZone=http://localhost:7070/eureka/ management.security.enabled=false info.version=@project.version@1
2
3
4
5
4、logback.xml(实现日志级别修改功能):
<configuration> <include resource="org/springframework/boot/logging/logback/base.xml"/> <jmxConfigurator/> </configuration>1
2
3
4
5、启动:
6、注意:
如果要监控注册到eureka的服务,必须要在这个服务里面引入:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>1
2
3
4
来开启一些管理功能,且须在配置文件加入一句:
management.security.enabled=false1
关闭安全验证。
代码托管:https://github.com/Lovnx/micro-service
相关文章推荐
- 使用spring boot admin监控spring cloud应用程序
- 详解使用spring boot admin监控spring cloud应用程序
- 详解使用spring boot admin监控spring cloud应用程序
- 使用Spirng Boot Admin监控Spring Cloud应用项目
- springboot(二十):使用spring-boot-admin对spring-boot服务进行监控
- 使用 Spring Boot Admin 来监控你的服务
- spring-boot使用Admin监控应用的方法
- spring-boot 之 使用Admin监控应用
- 使用spring-boot-admin对spring-boot服务进行监控
- spring-boot 之 使用Admin监控应用
- 详解Spring boot Admin 使用eureka监控服务
- spring boot(二十)使用spring-boot-admin对服务进行监控
- spring-boot 之 使用Admin监控应用
- springboot(二十):使用spring-boot-admin对spring-boot服务进行监控
- Spring cloud eureka+Client+Spring boot admin 服务注册监控
- spring-boot 之 使用Admin监控应用
- 使用spring-boot-admin对spring-boot服务进行监控
- 第1章 使用SpringBootAdmin监控度量信息