spring-boot-admin-starter-server监控springboot项目

文章目录

      • 场景
      • 实现
      • 具体操作
      • 展示

场景

监控三件套Prometheus、Grafana、Alertmanager 部署起来太复杂,如果公司没有运维而且项目很小就可以使用spring-boot-admin-starter-server替代。这个包使用起来还是很简单的, 下面就实现一个对springCloud项目的监控

实现

参考 项目

具体操作

  1. 引入包
    <dependencies>
        
        
        <dependency>
            <groupId>de.codecentricgroupId>
            <artifactId>spring-boot-admin-starter-serverartifactId>
            <version>2.2.0version>
        dependency>

        
        <dependency>
            <groupId>com.alibaba.cloudgroupId>
            <artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
            <version>2.2.0.RELEASEversion>
        dependency>
    dependencies>
  1. 配置文件参考
spring:
  profiles:
    active: test #默认运行环境
---
server:
  port: 9101
spring:
  profiles: test  #运行环境 + 命名空间名称
  application:
    name: admin-service   #唯一名称
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.56.18:8848  #Nacos 链接地址
        namespace: a60273f4-07fb-4568-82eb-d078a3b02107 #Nacos 命名空间ID
  1. 启动

启动类上添加注解 @EnableAdminServer

展示

spring-boot-admin-starter-server监控springboot项目_第1张图片

spring-boot-admin-starter-server监控springboot项目_第2张图片

你可能感兴趣的:(spring,boot,java,监控)