springboot之actuator监控管理

actuator监控管理

Actuator是Spring Boot的一个附加功能,可帮助你在应用程序生产环境时监视和管理应用程序。可以使用http的各种请求来监管、审计、收集应用的运行情况,特别对于微服务管理十分有意义。
Spring Boot提供了两种监控中心:
1、Actuator监控应用:没有界面,返回json格式;
2、AdminUI:底层使用的就是Actuator监控应用,实现可视化的界面;

监控内容

Actuator是Spring Boot的一个附加功能,可以在应用程序生产环境时监视和管理应用程序。可以使用http的各种请求来监管、审计、收集应用的运行情况。

集成

集成服务端

1、引入jar包

<!--  actuator监控中心  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--  支持admin-ui的关键配置  -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.2.2</version>
        </dependency>

2、增加注解@EnableAdminServer

@EnableAdminServer
@SpringBootApplication
public class OwnServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(OwnServiceApplication.class, args);
    }
}

3、查看http://localhost:60004/
在这里插入图片描述

集成监控端

1、引入jar包

<!--  支持admin-ui的关键配置  -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.2.2</version>
        </dependency>

2、直连模式增加配置
增加配置直连服务端

spring:
  boot:
    admin:
      client:
        url: http://localhost:60004/  #注册当前服务到服务端,服务端的地址
        instance:
          name: tbox
          prefer-ip: true #定义显示的名称

暴露配置

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS
    shutdown:
      enabled: true

3、启动项目再次访问
在这里插入图片描述
这时就可以看到监控应用已经注册到服务端
4、点击上方应用墙
看到实例,然后点击实例既可以看到该应用的监控信息
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值