2025年6月

SpringBoot介绍

Spring Boot对Spring平台和第三方库进行了整合,可创建可以运行的、独立的、生产级的基于Spring的应用程序。(大多数Spring Boot应用程序只需要很少的Spring配置)
Spring Boot可以使用java -jar或更传统的war部署启动的Java应用程序进行创建,可以内嵌Tomcat 、Jetty .Undertow容器,快速启动web程序。

设计目标
  • 为所有Spring开发提供更快且可通用的入门体验
  • 开箱即用,可以根据需求快速调整默认值。
  • 提供大型项目(例如嵌入式服务器、运行状况检查和统一配置)通用的一系列非功能性功能
  • 绝对没有代码生成,也不需要XML配置。

SpringBoot 优势对比预览

SpringBoot 优势快速预览
1. SpringMVC方式
(1) 修改pom.xml成类似以下的内容
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.study</groupId>
  <artifactId>spring-mvc</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>spring-mvc Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>5.1.5.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
    </dependency>
    
  </dependencies>
  <build>
    <finalName>spring-mvc</finalName>
  </build>
</project>
(2) 创建并修改web.xml成类似以下的内容
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    
    <!-- 编码过滤 -->
    <filter>
        <filter-name>CharacterEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>CharacterEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <!-- springMVC DispatcherServlet 配置 -->
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <!-- 指定配置文件 -->
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet> 
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>
(3) 创建并修改dispatcher-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
    
    <!-- 配置静态资源由web服务器的默认servlet处理 -->
    <mvc:default-servlet-handler />
    
    <!-- 启动注解支持 -->
    <mvc:annotation-driven/> 
    <!--
      <mvc:annotation-driven>  
           <mvc:message-converters register-defaults="true">  -->
               <!-- 避免IE执行AJAX时,返回JSON出现下载文件 -->  
              <!-- <bean id="fastJsonHttpMessageConverter" class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">  
                   <property name="supportedMediaTypes">  
                       <list>  
                           <value>application/json;charset=UTF-8</value>  
                       </list>  
                   </property>  
               </bean>  
           </mvc:message-converters>  
       </mvc:annotation-driven>         
    <mvc:default-servlet-handler/>
    -->
    
    <!-- 配置扫描注解组件的基础包 -->
    <context:component-scan base-package="com.**"/>
    
    
    <!-- 配置视图解析器 -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    </bean>
    
    <!-- 国际化配置 -->   
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages"/>
        <!-- <property name="basenames">
            <array>
                <value></value>
            </array>
        </property> -->
    </bean>
     
    <!-- 异常映射配置 -->
    <bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="defaultErrorView" value="/error/error"/>
        <property name="defaultStatusCode" value="500"/>
        <property name="exceptionMappings">
            <props>
                <prop key="java.sql.SQLException">/error/500</prop>
            </props>
        </property>
        <property name="warnLogCategory" value="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"/>
    </bean>
        
</beans>    
(4) 创建Controller
package cn.lazyfennec.mvc.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyController {

    @GetMapping("/index")
    public String index() {
        return "hello world";
    }
}
(5) 部署项目到tomcat
1
2
3
4
5
(6) 访问指定地址进行测试
6
2. SpringBoot方式
(1) 查看pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.8.BUILD-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>cn.lazyfennec</groupId>
    <artifactId>springBootDemo</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>springBootDemo</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
...  省略部分内容
(2) 创建controller

这里可以类似上方的mvc模式

(3) 运行并且进行测试

可以看到上方的两种方式的比较,SpringBoot的方式比较简单,非常快速,避免了很多的配置,并且无需配置tomcat相关的内容。


Maven工程使用SpringBoot

(1) pom.xml中加入以下内容
  • dependencyManagement
    <dependencyManagement>
        <dependencies>
            <dependency>
                <!--从SpringBoot导入依赖关系管理-->
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.1.3.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
  • dependencies
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
(2) 创建启动类
package cn.lazyfennec;

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

@SpringBootApplication//由本注解指定启动类
public class SpringBootDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootDemoApplication.class, args);
    }
}
(3) 创建Controller
package cn.lazyfennec.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MyController {

    @GetMapping("/index")
    public String index() {
        return "hello world";
    }
}

运行及打包

1.通过IDEA运行main方法

  1. maven插件运行: mvn spring-boot:run,需要添加spring-boot-maven-plugin到我们的pom.xml文件中

3.创建可执行的jar,需要添加spring-boot-maven-plugin到我们的pom.xml文件中

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
  • 打包命令: mvn package
  • 执行命令: java -jar xxx.jar
  • 注意事项: jar文件生成在target目录下,**..jar.original这个文件一般很小,这是打包可执行jar文件之前的原始jar

一些需要注意的东西

  • 程序入口: Main方法
@SpringBootApplication//由本注解指定启动类
public class SpringBootDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootDemoApplication.class, args);
    }
}
  • SpringBoot中通用的约定
  1. 注解扫码的包目录basePackage为启动类Main函数入口所在的包路
  2. 配置文件约定是classpath目录下的application.yml或者application.properties
  3. web开发的静态文件放在classpath,访问的顺序依次是:
    /META-INF/resources -> resources -> static -> public
  4. web开发中页面模板,约定放在classpath目录,/templates/目录下

如果觉得有收获就点个赞吧,更多知识,请点击关注查看我的主页信息哦~

原文链接:https://www.jianshu.com/p/6bb202cf92be

数据驱动:数据的改变从而驱动自动化测试用例的执行,最终引起测试结果的改变。简单说就是参数化的应用。

测试驱动在自动化测试中的应用场景:

  • 测试步骤的数据驱动;
  • 测试数据的数据驱动;
  • 配置的数据驱动;
1、pytest结合数据驱动-yaml

实现读yaml文件,先创建env.yml文件配置测试数据

工程目录结构:
  • data目录:存放yaml文件
-
  dev: 127.0.0.1
  #dev: 127.0.0.2
  #prod: 127.0.0.3
  • testcase目录:存放测试用例文件
import pytest
import yaml

class TestYaml:
    @pytest.mark.parametrize("env", yaml.safe_load(open("./env.yml")))
    def test_yaml(self, env):
        if "test" in env:
            print("这是测试环境")
            # print(env)
            print("测试环境的ip是:", env["test"])
        elif "dev" in env:
            print("这是开发文件")
            print("开发环境的ip是:", env["dev"])
            # print(env)

结果示例:


image.png
2、pytest结合数据驱动-excel

常用的读取方式有:xlrd、xlwings、pandas、openpyxl

以读excel文件,实现A+B=C并断言为例~
工程目录结构:
  • data目录:存放excel数据文件


    image.png
  • func目录:存放被测函数文件
def my_add(x, y):
    result = x + y
    return result
  • testcase目录:存放测试用例文件
import openpyxl
import pytest
from test_pytest.read_excel.func.operation import my_add

def test_get_excel():
    """
    解析excel数据
    :return: [[1,1,2],[3,6,9],[100,200,300]]
    """
    book = openpyxl.load_workbook('../data/param.xlsx')
    sheet = book.active
    cells = sheet["A1":"C3"]
    print(cells)
    values = []
    for row in sheet:
        data = []
        for cell in row:
            data.append(cell.value)
        values.append(data)
    print(values)
    return values

class TestWithExcel:
    @pytest.mark.parametrize('x,y,expected', test_get_excel())
    def test_add(self, x, y, expected):
        assert my_add(int(x), int(y)) == int(expected)
3、pyetst结合数据驱动-csv
csv:逗号文件,以逗号分隔的string文件
读取csv数据:
  • 内置函数open()
  • 内置模块csv
  • 方法:csv.reader(iterable)
  • 参数:iterable,文件或列表对象
  • 返回:迭代器,遍历迭代器,每次会返回一行数据
以读csv文件,实现A+B=C并断言为例~
工程目录结构:
  • data目录:存放csv数据文件


    image.png
  • func目录:存放被测函数文件
def my_add(x, y):
    result = x + y
    return result
  • testcase目录:存放测试用例文件
import csv
import pytest

from test_pytest.read_csv.func.operation import my_add

def test_get_csv():
    """
    解析csv文件
    :return:
    """
    with open('../data/params.csv') as file:
        raw = csv.reader(file)
        data = []
        for line in raw:
            data.append(line)
    print(data)
    return data

class TestWithCsv:
    @pytest.mark.parametrize('x,y,expected', test_get_csv())
    def test_add(self, x, y, expected):
        assert my_add(int(x), int(y)) == int(expected)
4、pytest结合数据驱动-json
json:js对象,是一种轻量级的数据交换格式。
json结构:
  • 对象{"key":value}
  • 数组[value1,value2...]
查看json文件:
  • 1.pycharm
  • 2.txt记事本
读取json文件:
  • 内置函数open()
  • 内置库json
  • 方法 json.loads() json.dumps()
以读json文件,实现A+B=C并断言为例~
工程目录结构:
  • data目录:存放json数据文件


    image.png
  • func目录:存放被测函数文件
def my_add(x, y):
    result = x + y
    return result
  • testcase目录:存放测试用例文件
import json
import pytest
from test_pytest.read_json.func.operation import my_add

def test_get_json():
    """
    解析json数据
    :return: [[1,1,2],[3,6,9],[100,200,300]]
    """
    with open('../data/params.json', 'r') as file:
        data = json.loads(file.read())
        print(list(data.values()))
        return list(data.values())

class TestWithJson:
    @pytest.mark.parametrize('x,y,expected', test_get_json())
    def test_add(self, x, y, expected):
        assert my_add(int(x), int(y)) == int(expected)

原文链接:https://www.jianshu.com/p/dd11812b2ba6

广度优先搜索

广度优先搜索(也称宽度优先搜索,缩写BFS即即Breadth First Search)是连通图的一种遍历算法。这一算法也是很多重要的图的算法的原型。Dijkstra单源最短路径算法和Prim最小生成树算法都采用了和广度优先搜索类似的思想。其属于一种盲目搜寻法,目的是系统地展开并检查图中的所有节点,以找寻结果。换句话说,它并不考虑结果的可能位置,彻底地搜索整张图,直到找到结果为止。基本过程,BFS是从根节点开始,沿着树(图)的宽度遍历树(图)的节点。

所采用的策略可概况为越早被访问到的顶点,其邻居顶点越早被访问。于是,从根顶点s的BFS搜索,将首先访问顶点s;再依次访问s所有尚未访问到的邻居;再按后者被访问的先后次序,逐个访问它们的邻居。一般用队列queue数据结构来辅助实现BFS算法。

二叉树的层序遍历

给你二叉树的根节点 root ,返回其节点值的 层序遍历 。 (即逐层地,从左到右访问所有节点)。


class Solution {
    /**
     * 思路:用队列存储每一层的数字,然后用变量记录当前层级元素的个数
     * 创建当前层级集合,遍历当前层级的size,弹出当列当前数添加到集合,判断当前节点左右节点是否为空,不为空加入到当前队列中
     * 注:每一层取当前层是从队列取前面数,存下一层是放入队列尾部,所以不会有冲突
     * @param root
     * @return
     */
    public List<List<Integer>> levelOrder(TreeNode root) {
        List<List<Integer>> res = new ArrayList<>();
        Queue<TreeNode> queue = new ArrayDeque<>();
        if (root != null) {
            queue.add(root);
        }

        while(!queue.isEmpty()) {
            //如果当前队列不为空,将当前队列的当前层弹出队列,存储数组中
            int size = queue.size();
            List<Integer> curLevel = new ArrayList<>();
            for (int i=0;i<size;i++) {
                //当前层级可以继续弹出
                TreeNode node = queue.poll();
                curLevel.add(node.val);
                if (node.left != null) {
                    queue.add(node.left);
                }
                if (node.right != null) {
                    queue.add(node.right);
                }
            }
            res.add(curLevel);
        }
        return res;
    }
}
深度优先搜索

深度优先搜索属于图算法的一种,是一个针对图和树的遍历算法,英文缩写为DFS即Depth First Search。深度优先搜索是图论中的经典算法,利用深度优先搜索算法可以产生目标图的相应拓扑排序表,利用拓扑排序表可以方便的解决很多相关的图论问题,如最大路径问题等等。一般用栈stack数据结构来辅助实现DFS算法。其过程简要来说是对每一个可能的分支路径深入到不能再深入为止,而且每个节点只能访问一次。

二叉树的最大深度

给定一个二叉树,找出其最大深度。

二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。

说明: 叶子节点是指没有子节点的节点。

题解:
class Solution {
     /**
     * 节点为空时说明高度为 0,所以返回 0;节点不为空时则分别求左右子树的高度的最大值,同时加1表示当前节点的高度,返回该数值
     * @param root
     * @return
     */
    public int maxDepth(TreeNode root) {
        if (root == null) {
            return 0;
        } else { //获取左子树的最大深度和右子树最大深度对比,选取大的,再+1,为当前节点的最大深度
            return Math.max(maxDepth(root.left), maxDepth(root.right)) + 1;
        }
    }
}
``

#### [二叉树的最小深度](https://leetcode.cn/problems/minimum-depth-of-binary-tree/)
给定一个二叉树,找出其最小深度。

最小深度是从根节点到最近叶子节点的最短路径上的节点数量。

说明:叶子节点是指没有子节点的节点。

#####题解:

class Solution {
public int minDepth(TreeNode root) {
//思路:得到树的最底层的叶子节点,即左右节点都为null,设置深度为1,从下往上找
//当前节点深度为取左右节点的深度较小值,+1,即当前节点最小深度作为函数返回值,该函数为递归调用函数
if(root == null) {
return 0;
}

    if(root.left == null && root.right == null) {
        return 1;
    }

    int mindepth = Integer.MAX_VALUE;
    if(root.left != null) {
        //左子节点不为空,得到左子节点的深度
        mindepth = Math.min(minDepth(root.left), mindepth);
    }
    if(root.right != null) {
        //右子节点不为空,得到右子节点的深度
        mindepth = Math.min(minDepth(root.right), mindepth);
    }
    return mindepth+1;
}

}






原文链接:https://www.jianshu.com/p/10720ee6e0e3

一、背景

用prometheus+grafana+redis_exporter监控redis,对redis 1主1从3哨兵 实例做一些业务分析。

prometheus、grafana安装机器: 192.168.1.101
redis_exporter 安装机器: 192.168.1.102

二、安装redis_exporter

在redis主从哨兵的maser节点(192.168.1.102):

wget https://github.com/oliver006/redis_exporter/releases/download/v0.21.2/redis_exporter-v0.21.2.linux-amd64.tar.gz

tar  -zxf  redis_exporter-v0.21.2.linux-amd64.tar.gz

mkdir  /usr/local/redis_exporter

mv  redis_exporter    /usr/local/redis_exporter/


vim  /usr/lib/systemd/system/redis_exporter.service
####################################################
[Unit]
Description=Redis Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=root
Group=root
Type=simple
ExecStart=/usr/local/redis_exporter/redis_exporter \
    -web.listen-address ":9121" \
    -redis.addr "redis://192.168.1.102:6381" \
    -redis.password "Redis@123"

[Install]
WantedBy=multi-user.target

####################################################

systemctl  daemon-reload

systemctl  start  redis_exporter
systemctl  enable  redis_exporter
systemctl  status  redis_exporter

ss  -tan  | grep 9121
LISTEN     0      1024      [::]:9121                  [::]:*
ESTAB      0      0       [::ffff:192.168.1.102]:9121                [::ffff:192.168.1.102]:42594



image.png

三、安装prometheus、grafana

在一台空闲新机器上:

安装prometheus

wget https://github.com/prometheus/prometheus/releases/download/v2.33.3/prometheus-2.33.3.linux-amd64.tar.gz
mkdir  /var/lib/prometheus
tar -zxf  prometheus-2.33.3.linux-amd64.tar.gz
mv  prometheus-2.33.3.linux-amd64  /usr/local/prometheus

vim   /usr/lib/systemd/system/prometheus.service
##################################################
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/usr/local/prometheus
ExecStart=/usr/local/prometheus/prometheus \
--web.listen-address=0.0.0.0:9090 \
--storage.tsdb.path="/var/lib/prometheus" \
--config.file=prometheus.yml
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target


##################################################

vim /usr/local/prometheus/prometheus.yml
############################################################################
# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  - job_name: "redis-server"
    static_configs:
      - targets: ["192.168.1.102:9121"]

###############################################################################


systemctl  start    prometheus
systemctl  enable   prometheus
systemctl  status  prometheus


# ss -tan | grep  -w  9090
LISTEN     0      65535     [::]:9090                  [::]:*

image.png

用浏览器访问:http://192.168.1.101:9090/

image.png
image.png

安装grafana

yum -y install  https://dl.grafana.com/oss/release/grafana-6.0.2-1.x86_64.rpm

systemctl  start  grafana-server
systemctl  enable  grafana-server
systemctl  status grafana-server
image.png

四、prometheus 和 grafana 集成

用浏览区打开 grafana web:http://192.168.1.101:3000
默认用户名和密码:admin

添加数据源 Prometheus,点击配置,点击 Data Sources


image.png
image.png
image.png
image.png
image.png
image.png
image.png

五、导入prometheus-redis_rev1.json模板

https://grafana.com/api/dashboards/763/revisions/1/download

image.png

如果启动多个redis实例,那么这个列表就会展示出所有的redis实例
上面也说到用redis_exporter 0.24版本,有redis.file 参数,可以将所有的redis实例写到一个文件中。

image.png
image.png

六、参考

Prometheus监控redis
https://www.cnblogs.com/layzer/articles/prometheus_redis.html

Grafana Prometheus系统监控Redis服务
https://blog.csdn.net/wyl9527/article/details/97151685

Prometheus监控Redis
https://blog.csdn.net/wc1695040842/article/details/107014209

Prometheus部署+简单监控
https://www.cnblogs.com/layzer/articles/prometheus_install_monitor.html

Prometheus 监控Redis的正确姿势(redis集群)
https://www.cnblogs.com/fsckzy/p/12053604.html

Prometheus 和 Grafana 集成
https://blog.csdn.net/weixin_45417821/article/details/123729143

prometheus.service启动、停止、重启、自启动
https://blog.csdn.net/qq_32014795/article/details/121852659

How to Setup a Redis Exporter for Prometheus
https://blog.ruanbekker.com/blog/2020/05/05/how-to-setup-a-redis-exporter-for-prometheus

原文链接:https://www.jianshu.com/p/08f5f436cb87