若依cloud -【 47 ~ 】

news2025/2/21 20:51:20

47 服务监控介绍

  • 什么是服务监控

        监视当前系统应用状态、内存、线程、堆栈、日志等等相关信息,主要目的在服务出现问题或者快要出现问题时能够准确快速地发现以减小影响范围。

  • 为什么要使用服务监控

        服务监控在微服务改造过程中的重要性不言而喻,没有强大的监控能力,改造微服务架构后,就无法掌控各个不同服务(多个)的情况,在遇到调用失败时,如果不能快速发现系统的问题,对于业务来说就是一场灾难。

  • spring boot actuator 服务监控接口

        actuator是监控系统健康情况的工具。

  • spring boot admin 服务监控管理

        Spring Boot Admin是一个针对spring-bootactuator接口进行UI美化封装的监控工具。他可以:在列表中浏览所有被监控spring-boot项目的基本信息,详细的Health信息、内存信息、JVM信息、垃圾回收信息、各种配置信息(比如数据源、缓存列表和命中率)等,还可以直接修改logger的level。

48 服务监控使用

1、添加依赖



<!-- SpringBoot Web,支持使用启动类(Application.java)启动微服务 -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- 
     SpringBoot Actuator , actuator是监控系统健康情况的工具。
     有一系列的接口,我们可以直接用。
-->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2、在application.yml配置暴露所有监控端点

server:
  port: 9100
spring:
  application:
    name: ruoyi-admin-web

# 其实不配置也没有问题。
# 如果不配置,就默提供(暴露)少许的几个接口给外部。
# 根据实际情况决定要不要配置。
# 一般情况下我们会使用以下配置暴露所有的接口。这样的话,他提供的所有的接口啊,都会被我们发现。
management:
  endpoints:
    web:
      exposure:
        include: '*'

3、监控启动类

@SpringBootApplication
public class RuoYiMonitorApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(RuoYiMonitorApplication.class, args);
        System.out.println("(♥◠‿◠)ノ゙  监控中心启动成功   ლ(´ڡ`ლ)゙  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }
}

4、测试验证

  1. 重启后端
  2. 启动后访问http://localhost:9100/actuator,返回正确数据表示测试通过。
    暴露少许几个:
    暴露所有:

49 服务监控端点分类

        浏览器访问localhost:9100/actuator时,页面中显示的是很多各种可以访问的地址组成的json字符串:

地址描述
/beans显示所有注册到spring容器中的Spring bean的列表
/caches显示所有的缓存相关信息。spring boot提供的缓存注解,有兴趣的可以试一下。
/scheduledtasks显示所有的定时任务相关信息。
/loggers显示所有的日志相关信息。可以看到所有的包的日志的级别,都可以显示出来。
/configprops显示所有的配置信息。比如在application.yml中配置的端口9100,可以使用 Ctrl+F 搜索出来。
/env显示所有的环境变量信息。比如Ant的信息、jdk的信息。
/mappings显示所有控制器相关信息。控制器:定义的访问接口
/info显示自定义用户信息配置。注意:/info需要自己去定义,否则会显示空(null)。如下图所示:
/metrics显示应用指标相关信息。如jvm的相关参数、tomcat的相关参数、http的相关参数。
/health显示健康检查状态信息,up表示成功 down表示失败。
/threaddump显示程序线程的信息。因为程序里边有很多线程。
{
    "_links": {
        "self": {
            "href": "http://localhost:9100/actuator",
            "templated": false
        },
        "beans": {
            "href": "http://localhost:9100/actuator/beans",
            "templated": false
        },
        "caches-cache": {
            "href": "http://localhost:9100/actuator/caches/{cache}",
            "templated": true
        },
        "caches": {
            "href": "http://localhost:9100/actuator/caches",
            "templated": false
        },
        "health": {
            "href": "http://localhost:9100/actuator/health",
            "templated": false
        },
        "health-path": {
            "href": "http://localhost:9100/actuator/health/{*path}",
            "templated": true
        },
        "info": {
            "href": "http://localhost:9100/actuator/info",
            "templated": false
        },
        "conditions": {
            "href": "http://localhost:9100/actuator/conditions",
            "templated": false
        },
        "configprops": {
            "href": "http://localhost:9100/actuator/configprops",
            "templated": false
        },
        "configprops-prefix": {
            "href": "http://localhost:9100/actuator/configprops/{prefix}",
            "templated": true
        },
        "env": {
            "href": "http://localhost:9100/actuator/env",
            "templated": false
        },
        "env-toMatch": {
            "href": "http://localhost:9100/actuator/env/{toMatch}",
            "templated": true
        },
        "loggers": {
            "href": "http://localhost:9100/actuator/loggers",
            "templated": false
        },
        "loggers-name": {
            "href": "http://localhost:9100/actuator/loggers/{name}",
            "templated": true
        },
        "heapdump": {
            "href": "http://localhost:9100/actuator/heapdump",
            "templated": false
        },
        "threaddump": {
            "href": "http://localhost:9100/actuator/threaddump",
            "templated": false
        },
        "metrics-requiredMetricName": {
            "href": "http://localhost:9100/actuator/metrics/{requiredMetricName}",
            "templated": true
        },
        "metrics": {
            "href": "http://localhost:9100/actuator/metrics",
            "templated": false
        },
        "scheduledtasks": {
            "href": "http://localhost:9100/actuator/scheduledtasks",
            "templated": false
        },
        "mappings": {
            "href": "http://localhost:9100/actuator/mappings",
            "templated": false
        },
        "refresh": {
            "href": "http://localhost:9100/actuator/refresh",
            "templated": false
        },
        "features": {
            "href": "http://localhost:9100/actuator/features",
            "templated": false
        }
    }
}

50 服务监控整合Admin-Ui:使用admin-ui格式化显示上面的json数据。

1、添加依赖

<!-- SpringBoot Admin -->
<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-server</artifactId>
	<version>${spring-boot-admin.version}</version>
</dependency>

2、监控启动类

@EnableAdminServer
@SpringBootApplication
public class RuoYiMonitorApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(RuoYiMonitorApplication.class, args);
        System.out.println("(♥◠‿◠)ノ゙  监控中心启动成功   ლ(´ڡ`ლ)゙  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }
}

3、测试访问

浏览器访问(http://localhost:9100 (opens new window))可以看到以下界面。

monitor

4、注意:还需要去配置客户端

51 服务监控客户端配置

   之前已经把Admin(actuator工具 + Admin-Ui)服务跑起来了,但是界面里边什么应用都没有(0应用、0实例数)。因此需要加一个客户端,然后给(actuator工具 + Admin-Ui)服务进行监控。

0、新建客户端模块ruoyi-admin-client

1、pom.xml:添加依赖

<!-- SpringBoot Web,支持使用启动类(Application.java)启动微服务 -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- SpringBoot Admin Client -->
<dependency>
	<groupId>de.codecentric</groupId>
	<artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>

<!-- SpringBoot Actuator -->
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2、application.yml:配置服务端地址

server:
  port: 9200

# 注意放开端点,不然看到的信息非常少(只能看到默认的那几个)  
management:
  endpoints:
    web:
      exposure:
        include: '*'
spring:
  application:
    name: ruoyi-admin-client
  boot:
    admin:
      client:
        # 指向服务端的ip + port
        url: http://localhost:9100

3、RuoyiClientApplication.java:启动类:去掉

package com.ruoyi.client;


import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RuoYiClientApplication
{
    public static void main(String[] args)
    {
        SpringApplication.run(RuoYiClientApplication.class, args);
        System.out.println("(♥◠‿◠)ノ゙  监控中心启动成功   ლ(´ڡ`ლ)゙  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }
}

4、测试验证

  1. 重启服务端、客户端
  2. 访问:服务端http://localhost:9100/
  3. 效果:展示客户端的所有信息。这个页面展示的信息,只是把之前的端点分类的所有接口(地址)都访问一遍,然后全部都用可视化界面进行展示。方便我们去分析整个应用情况:

 

 

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/941066.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Linux操作系统--shell编程(正则表达式)

1..正则表达式概述 正则表达式使用单个字符串来描述、匹配一系列符合某个语法规则的字符串。在很多文本编辑器里,正则表达式通常被用来检索、替换那些符合某个模式的文本。在 Linux 中,grep,sed,awk 等文本处理工具都支持通过正则表达式进行模式匹配。 2.常规的匹配操作 3.…

电源防反接电路设计

NMOS防反接&#xff1a; PMOS防反接 在实际应用中&#xff0c;G极一般串联一个电阻&#xff0c;防止MOS管被击穿&#xff0c;也可以加上稳压二极管&#xff0c;并联在分压电阻上的电容&#xff0c;有一个软启动的作用。在电流开始流过的瞬间&#xff0c;电容充电&#xff0c;G极…

一键快速还原修复人脸,CodeFormer 助力人脸图像修复

今天在查资料的时候无意间看到了一个很有意思的工具&#xff0c;就是CodeFormer &#xff0c;作者给出来的说明是用于人脸修复任务的&#xff0c;觉得很有意思就拿来实践了一下&#xff0c;这里记录分享一下。 首先对人脸修复任务进行简单的回顾总结&#xff1a; 人脸修复是指…

thinkphp6 入门(3)--获取GET、POST请求的参数值

一、Request对象 thinkphp提供了Request对象&#xff0c;其可以 支持对全局输入变量的检测、获取和安全过滤 支持获取包括$_GET、$_POST、$_REQUEST、$_SERVER、$_SESSION、$_COOKIE、$_ENV等系统变量&#xff0c;以及文件上传信息 具体参考&#xff1a;https://www.kanclou…

功率放大器选购注意什么问题

功率放大器是将输入信号放大到较高功率输出的重要设备。在选择功率放大器时&#xff0c;需要考虑多个因素&#xff0c;以确保所购买的设备能够满足实际需求。下面西安安泰将介绍一些功率放大器的关键问题和注意事项&#xff0c;帮助大家在功率放大器选购过程中做出明智的决策。…

CentOs下面安装jenkins记录

目录 一、安装jenkins 二、进入jenkins 三、安装和Gitee&#xff0c;Maven等插件 一、安装jenkins 1 wget -O /etc/yum.repos.d/jenkins.repo \ https://pkg.jenkins.io/redhat-stable/jenkins.repo 2 rpm --import https://pkg.jenkins.io/redhat-stable/…

接口测试json入参,不同类型参数格式书写

接口json入参&#xff0c;不同类型参数格式 1、String 入参&#xff1a;A&#xff08;String&#xff09;&#xff0c;B&#xff08;String&#xff09; 格式&#xff1a;{"A":"值a","B":"值b"} 示例&#xff1a; 接口测试入参这么…

多个版本python本地调用解决方案

当本机既装了2点几的python又装的3点几的python的时候&#xff0c;在环境变量里面&#xff0c;哪一个的路径在path里面配置的考前&#xff0c;哪个就会被识别到。 如果想使用3点几的python怎么搞呢&#xff1f; 输入指令 where python&#xff0c; 找到你要的python路径&#…

基于Ubuntu坏境下的Suricata坏境搭建

目录 Suricata环境安装 第一步、在 Ubuntu 端点安装 Suricata 1、加入Suricata源 2、更新安装包 3、下载SuricataSuricata 第二步、下载并提取新兴威胁 Suricata 规则集 1、在tmp文件夹下载 Suricata 规则集 如果发现未安装curl&#xff0c;使用apt安装即可&#xff1a;…

【数据结构】详解环形队列

文章目录 &#x1f30f;引言&#x1f340;[循环队列](https://leetcode.cn/problems/design-circular-queue/description/)&#x1f431;‍&#x1f464;题目描述&#x1f431;‍&#x1f453;示例&#xff1a;&#x1f431;‍&#x1f409;提示&#x1f431;‍&#x1f3cd;思…

图像特征描述和人脸识别

CV_tutorial2 特征检测使用HOG实现行人检测Harris角点检测关键特征检测SIFT纹理特征 LBP算法 模板匹配人脸识别 特征检测 使用HOG实现行人检测 HOG方向梯度直方图 实现过程&#xff1a; 灰度化&#xff08;为了去掉颜色、光照对形状的影响&#xff09;;采用Gamma校正法对输…

拉美市场,跨境电商的最后一片蓝海市场?真的值得入场吗?

拉美&#xff0c;是跨境卖家公认的蓝海市场&#xff0c;甚至经常被称为“跨境电商的最后一片蓝海市场”。那么拉美市场的前景究竟如何&#xff1f;现在真的是跨境卖家入场的最佳时机吗&#xff1f;接下来就一起来看一看吧&#xff01; 拉美市场基本概况 1、消费潜力大&#x…

软件测试工程师必会技术:Python带你上手WebSocket

关于Socket那些事 Socket&#xff0c;即网络套接字&#xff0c;是双向通信通道的端点&#xff08;是抽象的&#xff09;。 套接字可以在一个进程内、同一台机器上的进程之间&#xff0c;或者在不同机器上的进程之间进行通信。 网络套接字可以通过多种不同的通道类型得以实现…

[ 云计算 | AWS ] Java 应用中使用 Amazon S3 进行存储桶和对象操作完全指南

文章目录 一、前言二、所需 Maven 依赖三、先决必要的几个条件信息四、创建客户端连接五、Amazon S3 存储桶操作5.1. 创建桶5.2. 列出桶 六、Amazon S3 对象操作6.1. 上传对象6.2. 列出对象6.3. 下载对象6.4. 复制、重命名和移动对象6.5. 删除对象6.6. 删除多个对象 七、文末总…

Linux 云服务器挂载数据盘

1、检查linux服务器磁盘情况 df -h 可以看到无磁盘挂载信息。 2、查看待挂载磁盘信息 fdisk -l 可以看到40G系统盘、50G数据盘&#xff08;盘符&#xff1a;/dev/vdb&#xff09; 3、对数据盘分区 fdisk /dev/vdb 根据提示&#xff0c;依次输入“n”&#xff0c;“p”“1…

ModaHub魔搭社区:向量数据库产业的现状与技术挑战

I. 向量数据库的崛起 什么是向量数据库 在过去的一段时间里,向量数据库逐渐在数据库领域崭露头角。那么,什么是向量数据库呢?简单来说,向量数据库是一种专门设计用来处理向量数据的数据库。这些向量数据可以是物理测量、机器学习模型输出、地理空间数据等。向量数据库使用…

归纳整理:开发多用户商城系统的关键细节

电子商务的迅速发展&#xff0c;越来越多的企业和商家选择开发多用户商城系统来进入线上商城市场。然而&#xff0c;在选择和开发多用户商城系统时&#xff0c;有一些关键的细节需要特别关注&#xff0c;以确保系统的顺利运行和用户的满意度。 一、安全性与数据保护 多用户商城…

浅析SAS协议:链路层

文章目录 概述原语通用原语连接管理原语连接通信原语 地址帧IDENTIFY地址帧OPEN地址帧 链路复位Link ResetHard ResetSATA的Link Reset 连接管理建立连接连接仲裁 流量控制SSP流控Credit Advance SMP流控 相关参考 概述 SAS链路层用于定义原语、地址帧以及连接相关的内容&…

和鲸冠名,全权支持!全国高校青年教师数据科学与商业分析案例教学竞赛成功举办

为推动数据科学与商业分析领域教学模式的创新&#xff0c;以赛促教&#xff0c;激发教师们的教学热情和创新能力&#xff0c;以赛促创&#xff0c;激发学生们的创新潜能和能动性&#xff0c;中国商业统计学会举办了首届“和鲸杯”全国高校青年教师数据科学与商业分析案例教学竞…

关于yarn安装时报“node“ is incompatible with this module的解决办法

前提&#xff1a; 在用vue写一个h5页面时&#xff0c;当在用yarn安装时&#xff0c;提示如下错误&#xff1a; The engine “node” is incompatible with this module. Expected version "^14.18.0 || ^16.14.0 || >18. 解决办法 我是使用命令忽略错误&#xff1a…