当前位置:   article > 正文

SPRING BOOT 基于ACTUATOR监控中心搭建ADMINUI_spring boot actuator admin-ui

spring boot actuator admin-ui

Github

https://github.com/983674707/AdminUi

Actuator

什么是监控中心(针对微服务服务的监控):
1.服务器内存变化(堆内存 线程 日志管理等),
2.检测服务器配置连接地址是否可用(模拟访问,懒加载),
3.统计多个bean(是spring容器的bean),
4.统计springMVC @RequestMapping(统计http接口)。


Actuator监控应用(没有界面,返回json格式)
AdminUi 底层使用了Actuator监控应用 ,实现可视化界面
应用场景:生产环境

配置

pom.xml

 

1

2

3

4

5

6

7

8

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-web</artifactId>

        </dependency>

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-actuator</artifactId>

        </dependency>

application.yml

 

1

2

3

4

5

6

##通过下面的配置启动所有夫人监控端点,默认情况下,这下端点是禁用的

management:

  endpoints:

    web:

      exposure:

        include: "*"

如果不加这段配置
##默认情况下,监控中心提供三个接口权限。
在SpringBoot2.0之后, 监控中心的接口地址发生变化:
2.0:http://localhost:2018/actuator/beans
1.5:http://localhost:2018/beans

AdminUi配置

server

pom.xml

 

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

    <parent>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-parent</artifactId>

        <version>2.0.5.RELEASE</version>    ##必须是2.0以上

        <relativePath/>

    </parent>

        <dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter</artifactId>

</dependency>

<dependency>

<groupId>de.codecentric</groupId>

<artifactId>spring-boot-admin-starter-server</artifactId>

<version>2.0.0</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-webflux</artifactId>

</dependency>

<dependency>

<groupId>org.jolokia</groupId>

<artifactId>jolokia-core</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-actuator</artifactId>

</dependency>

<dependency>

<groupId>com.googlecode.json-simple</groupId>

<artifactId>json-simple</artifactId>

<version>1.1</version>

</dependency>

 

</dependencies>

启动类

@EnableAdminServer

application.yml

 

1

2

3

4

5

server:

  port: 2001

spring:

  application:

    name: AdminUi-Server

 

client

pom.xml

 

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

     <parent>

        <groupId>org.springframework.boot</groupId>

        <artifactId>spring-boot-starter-parent</artifactId>

        <version>2.0.5.RELEASE</version>

        <relativePath/>

    </parent>

       <dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter</artifactId>

</dependency>

<dependency>

<groupId>de.codecentric</groupId>

<artifactId>spring-boot-admin-starter-client</artifactId>##与server不同的地方

<version>2.0.0</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-webflux</artifactId>

</dependency>

<dependency>

<groupId>org.jolokia</groupId>

<artifactId>jolokia-core</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-actuator</artifactId>

</dependency>

<dependency>

<groupId>com.googlecode.json-simple</groupId>

<artifactId>json-simple</artifactId>

<version>1.1</version>

</dependency>

 

</dependencies>

启动类

 

1

2

3

4

5

6

7

@SpringBootApplication ##只有这一个注解

public class AdminuiClientApplication {

 

    public static void main(String[] args) {

        SpringApplication.run(AdminuiClientApplication.class, args);

    }

}

application.yml

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

##表明server地址

spring:

  boot:

    admin:

      client:

        url: http://localhost:2001

##端口

server:

  port: 2002

##Actuator监控的权限(全开*)

management:

  endpoints:

    web:

      exposure:

        include: "*"

 

AdminUi

AdminUi

AdminUi

AdminUi

AdminUi

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/101871
推荐阅读
相关标签
  

闽ICP备14008679号