赞
踩
// 文档指南
文档使用 Prometheus数据源 和 Redis数据源 两种数据源选择来监控Redis,主要以Prometheus数据源为主
监控的组成部分:
文档中的的准备工作(redis主从 和 redis集群)主要是为了方便演示配置,实际尝试部署的时候准备简单的主从架构就可以
感觉麻烦 或者 想快速部署先看看效果 也可以使用我的部署脚本
IP | port | role |
---|---|---|
50.50.50.100 | 6379 | master |
50.50.50.100 | 6380 | slave |
50.50.50.100 | 6381 | slave |
IP | port | role |
---|---|---|
50.50.50.100 | 7000 | master |
50.50.50.100 | 7001 | master |
50.50.50.100 | 7002 | master |
50.50.50.100 | 7003 | slave |
50.50.50.100 | 7004 | slave |
50.50.50.100 | 7005 | slave |
https://prometheus.io/download/
部署 prometheus 作为监控系统的核心组件,负责收集、存储和查询来自 redis_exporter node_exporter 的指标数据,并提供给Grafana进行可视化展示
安装 redis_exporter、node_exporter 插件
配置 prometheus 连接 redis_exporter、node_exporter
访问 prometheus web 界面查看
https://github.com/prometheus/prometheus
prometheus-2.45.2.linux-amd64.tar.gz
tar -zxf prometheus-2.45.2.linux-amd64.tar.gz
mkdir /usr/local/prometheus
mv prometheus-2.45.2.linux-amd64 /usr/local/prometheus/prometheus-2.45.2
cd /usr/local/prometheus/prometheus-2.45.2
vim 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:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "A_prometheus_9099"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
#
static_configs:
- targets: ["50.50.50.100:9099"]
vim /usr/lib/systemd/system/prometheus.service
[Unit]
Description=https://prometheus.io
[Service]
Restart=on-failure
ExecStart=/usr/local/prometheus/prometheus-2.45.2/prometheus \
--storage.tsdb.path=/usr/local/prometheus/prometheus-2.45.2/data \
--config.file=/usr/local/prometheus/prometheus-2.45.2/prometheus.yml \
--web.listen-address=:9099
[Install]
WantedBy=multi-user.target
systemctl start prometheus.service
systemctl enable prometheus.service
node_exporter 是 Prometheus 的一个插件,用于收集和暴露系统级别的监控指标
它可以在被监控的主机上运行,并通过HTTP接口提供各种系统指标,如CPU使用率、内存使用率、磁盘空间、网络流量等。这些指标可以被 Prometheus 服务器收集和存储,然后用于监控和报警
通过安装和配置 node_exporter 插件,Prometheus 可以实时监控被监控主机的各种系统指标,并将其存储在时间序列数据库中
这样,用户可以使用 Prometheus 的查询语言(PromQL)来查询和分析这些指标,并根据需要创建自定义的监控规则和报警
https://github.com/prometheus/node_exporter
node_exporter-1.7.0.linux-amd64.tar.gz
tar -zxf node_exporter-1.7.0.linux-amd64.tar.gz
mv node_exporter-1.7.0.linux-amd64 /usr/local/prometheus/node_exporter-1.7.0
[Unit]
Description=Prometheus node_exporter
[Service]
User=root
ExecStart=/usr/local/prometheus/node_exporter-1.7.0/node_exporter
ExecStop=/usr/bin/killall node_exporter
[Install]
WantedBy=default.target
systemctl start prometheus.service
systemctl enable redis_exporter.service
vim /usr/local/prometheus/prometheus-2.45.2/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:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "A_prometheus_9099"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
#
static_configs:
- targets: ["50.50.50.100:9099"]
- job_name: "A_exporter_node_9100"
static_configs:
- targets: ['50.50.50.100:9100']
systemctl restart prometheus.service
redis_exporter 中的作用是用于监控和收集 Redis 数据库的性能指标
它是一个用于 Prometheus 的 Redis 监控导出器,可以通过暴露 Redis 服务器的指标来实时监控 Redis 数据库的运行状态
redis_exporter 会定期从 Redis 服务器获取指标数据,并将其提供给 Prometheus 进行存储和分析
通过将 redis_exporter 与 Prometheus 集成,您可以实时监控 Redis 的运行状况,并使用 Prometheus 的强大查询和可视化功能来分析和展示这些指标数据
https://github.com/oliver006/redis_exporter
redis_exporter-v1.47.0.linux-amd64.tar.gz //稳定版本
tar -zxf redis_exporter-v1.56.0.linux-amd64.tar.gz
mv redis_exporter-v1.47.0.linux-amd64.tar.gz /usr/local/prometheus/redis_exporter-1.47.0
cd /usr/local/prometheus/redis_exporter-1.47.0
mkdir password_file
vim redis-cluster-password.json
{
"redis://50.50.50.100:7000": "redis-password-1",
"redis://50.50.50.100:7001": "redis-password-1",
"redis://50.50.50.100:7002": "redis-password-1",
"redis://50.50.50.100:7003": "redis-password-1",
"redis://50.50.50.100:7004": "redis-password-1",
"redis://50.50.50.100:7005": "redis-password-1"
}
vim redis-sentinel-password.json
{
"redis://50.50.50.100:6379": "redis-password-2",
"redis://50.50.50.100:6380": "redis-password-2",
"redis://50.50.50.100:6381": "redis-password-2"
}
cd /usr/local/prometheus/redis_exporter-1.47.0
mkdir script && mkdir logs
cd /usr/local/prometheus/redis_exporter-1.47.0/script
vim redis-cluster-9121.sh
#!/bin/bash
INSTALL_PATH=/usr/local/prometheus/redis_exporter-v1.47.0
PASSWORD_FILE=$INSTALL_PATH/password_file/redis-cluster-password.json
REDIS_ADDR=50.50.50.100:7000
PORT=9121
nohup $INSTALL_PATH/redis_exporter \
-redis.addr $REDIS_ADDR \
-redis.password-file $PASSWORD_FILE \
-web.listen-address :$PORT \
> $INSTALL_PATH/logs/redis-cluster-9121 &
vim redis-sentinel-9122.sh
#!/bin/bash
INSTALL_PATH=/usr/local/prometheus/redis_exporter-v1.47.0
PASSWORD_FILE=$INSTALL_PATH/password_file/redis-sentinel-password.json
REDIS_ADDR=50.50.50.100:6379
PORT=9122
nohup $INSTALL_PATH/redis_exporter \
-redis.addr $REDIS_ADDR \
-redis.password-file $PASSWORD_FILE \
-web.listen-address :$PORT \
> $INSTALL_PATH/logs/redis-sentinel-9122 &
sh redis-cluster-9121.sh
sh redis-sentinel-9122.sh
echo '/bin/sh /usr/local/prometheus/redis_exporter-1.47.0/script/redis-cluster-9121.sh' >> /etc/rc.d/rc.local
echo '/bin/sh /usr/local/prometheus/redis_exporter-1.47.0/script/redis-sentinel-9122.sh' >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
以下是进行调试时使用的参数 -debug 和 指定 redis 集群模式的参数 -is-cluster=true
由于选择集群 -is-cluster=true 在使用 -redis.password-file 时无法读取密码文件(至少我在测试的时候没有读取到密码,也不知道是集群的密码配置会有区别还是 bug),所以上面的集群模式我没有使用 -is-cluster=true 参数
如果想使用 -is-cluster=true 参数导出,那么可以使用 -redis.password 来指定密码(不过这样会有一个问题,密码明文会暴露在进程中)
# ./redis_exporter -redis.addr 50.50.50.100:6379 -redis.password-file sample-pwd-file.json -debug
# ./redis_exporter -redis.addr 50.50.50.100:7000 -redis.password redis-password -is-cluster=true -debug
如果出现以下日志输出为正常,应该是 redis_exporter 这条日志输出级别设置错了
提示你配置加载自哪里,level 应该是 info 而不是 error,忽略就可以
time="2024-01-29T17:08:06+08:00" level=error msg="Loaded 3 entries from
配置 prometheus 连接 redis_exporter 端口用于检测存活
vim /usr/local/prometheus/prometheus-2.45.2/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:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "A_prometheus_9099"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
#
static_configs:
- targets: ["50.50.50.100:9099"]
- job_name: "A_exporter_node_9100"
static_configs:
- targets: ['50.50.50.100:9100']
- job_name: "A_exporter_redis_9121"
static_configs:
- targets: ['50.50.50.100:9121']
- job_name: "A_exporter_redis_9122"
static_configs:
- targets: ['50.50.50.100:9122']
systemctl restart prometheus.service
浏览器访问 prometheus 50.50.50.100:9099
查看 prometheus、node_exporter、redis_exporter 是否存活
http://50.50.50.100:9099/
配置 prometheus 连接 redis_exporter 端口,用于抓取多个 Redis 主机
cd /usr/local/prometheus/prometheus-2.45.2
vim 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:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'A_prometheus_9099'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
#
static_configs:
- targets: ["50.50.50.100:9099"]
- job_name: 'A_exporter_node_9100'
static_configs:
- targets: ['50.50.50.100:9100']
# redis exporter prot
- job_name: 'A_exporter_redis_9121'
static_configs:
- targets: ['50.50.50.100:9121']
- job_name: 'A_exporter_redis_9122'
static_configs:
- targets: ['50.50.50.100:9122']
# redis exporter
- job_name: 'text_A_redis_cluaster'
file_sd_configs:
- files:
- redis_exporter_conf/text_A_redis_cluaster.json
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 50.50.50.100:9121
- job_name: 'text_B_redis_sentinel'
file_sd_configs:
- files:
- redis_exporter_conf/text_B_redis_sentinel.json
metrics_path: /scrape
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 50.50.50.100:9122
systemctl restart prometheus
配置 prometheus 热加载文件,用于抓取 redis_exporter 导出的redis指标
cd /usr/local/prometheus/prometheus-2.45.2 && mkdir redis_exporter_conf
cd redis_exporter_conf
vim text_A_redis_cluaster.json
[
{
"targets": [ "redis://50.50.50.100:7000",
"redis://50.50.50.100:7001",
"redis://50.50.50.100:7002",
"redis://50.50.50.100:7003",
"redis://50.50.50.100:7004",
"redis://50.50.50.100:7005" ],
"labels": { }
}
]
vim text_B_redis_sentinel.json
[
{
"targets": [ "redis://50.50.50.100:6379",
"redis://50.50.50.100:6380",
"redis://50.50.50.100:6381" ],
"labels": { }
}
]
配置热加载无需重启 prometheus
浏览器访问 prometheus 查看 redis 存活状态
查看 redis_exporter 导出的redis指标
部署 Grafana,使用 Prometheus 数据源 将 Prometheus 收集到的数据整合到 Grafana 进行展示
https://grafana.com/grafana/download?pg=graf&plcmt=deploy-box-1
grafana-enterprise-8.5.2-1.x86_64.rpm
yum install -y grafana-enterprise-8.5.2-1.x86_64.rpm
systemctl start grafana-server.service
systemctl enable grafana-server.service
http://50.50.50.100:3000/
关于 Grafana 的主题可以修改 default_theme 参数
配置文件在 /etc/grafana/grafana.ini
添加 redis_exporter 仪表盘展示模板
我这里用的仪表盘模板 ID 763
添加面板使用 PromQL 语句实现 role、link、存活状态的展示
count by (role) (redis_instance_info{instance=~"$instance"})
{{role}}
redis_master_link_up{instance=~"$instance"}
master {{master_host}}:{{master_port}}
redis_connected_slave_lag_seconds{instance=~"$instance"}
slave {{slave_ip}}:{{slave_port}}
{
"__inputs": [
{
"name": "DS_业务",
"label": "业务",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__elements": [],
"__requires": [
{
"type": "panel",
"id": "gauge",
"name": "Gauge",
"version": ""
},
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "8.5.2"
},
{
"type": "panel",
"id": "graph",
"name": "Graph (old)",
"version": ""
},
{
"type": "panel",
"id": "piechart",
"name": "Pie chart",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
},
{
"type": "panel",
"id": "stat",
"name": "Stat",
"version": ""
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "datasource",
"uid": "grafana"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"description": "Redis Dashboard for Prometheus Redis Exporter 1.x",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 763,
"graphTooltip": 1,
"id": null,
"iteration": 1712656187874,
"links": [],
"liveNow": true,
"panels": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"0": {
"color": "dark-red",
"index": 1
},
"1": {
"color": "dark-green",
"index": 0
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 2,
"w": 24,
"x": 0,
"y": 0
},
"id": 34,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "vertical",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"textMode": "none"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "redis_up{namespace!=\"\"}",
"legendFormat": "{{label_name}}",
"range": true,
"refId": "A"
}
],
"title": "整体存活状态",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 4,
"x": 0,
"y": 2
},
"id": 22,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"text": {
"valueSize": 45
},
"textMode": "name"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "count by (role) (redis_instance_info{instance=~\"$instance\"})",
"legendFormat": "{{role}}",
"range": true,
"refId": "A"
}
],
"title": "角色",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [
{
"options": {
"0": {
"color": "dark-red",
"index": 1,
"text": "DOWN"
},
"1": {
"color": "dark-green",
"index": 0,
"text": "UP"
}
},
"type": "value"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 6,
"x": 4,
"y": 2
},
"id": 28,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"text": {
"titleSize": 15,
"valueSize": 15
},
"textMode": "auto"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "redis_up{namespace=~\"$namespace\"}",
"legendFormat": "{{instance}} ~❤️",
"range": true,
"refId": "A"
}
],
"title": "存活状态",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"description": "",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 7,
"x": 10,
"y": 2
},
"id": 24,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"text": {
"valueSize": 30
},
"textMode": "name"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "redis_master_link_up{instance=~\"$instance\", namespace=~\"$namespace\"}",
"legendFormat": "master {{master_host}}:{{master_port}}",
"range": true,
"refId": "A"
}
],
"title": "主链接",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 7,
"x": 17,
"y": 2
},
"id": 26,
"options": {
"colorMode": "none",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"text": {
"valueSize": 30
},
"textMode": "name"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "redis_connected_slave_lag_seconds{instance=~\"$instance\", namespace=~\"$namespace\"}",
"legendFormat": "slave {{slave_ip}}:{{slave_port}}",
"range": true,
"refId": "A"
}
],
"title": "从链接",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "rgb(31, 120, 193)",
"mode": "fixed"
},
"decimals": 0,
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 3,
"x": 0,
"y": 9
},
"id": 9,
"links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "none",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {
"valueSize": 55
},
"textMode": "auto"
},
"pluginVersion": "8.5.2",
"targets": [
{
"expr": "max(max_over_time(redis_uptime_in_seconds{instance=~\"$instance\"}[$__interval]))",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "",
"metric": "",
"refId": "A",
"step": 1800
}
],
"title": "最长正常运行时间",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "rgb(31, 120, 193)",
"mode": "fixed"
},
"decimals": 0,
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 5,
"x": 3,
"y": 9
},
"hideTimeOverride": true,
"id": 12,
"links": [],
"maxDataPoints": 100,
"options": {
"colorMode": "none",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"text": {
"valueSize": 60
},
"textMode": "auto"
},
"pluginVersion": "8.5.2",
"targets": [
{
"expr": "sum(redis_connected_clients{instance=~\"$instance\"})",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "",
"metric": "",
"refId": "A",
"step": 2
}
],
"timeFrom": "1m",
"title": "客户",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"decimals": 0,
"mappings": [
{
"options": {
"match": "null",
"result": {
"text": "N/A"
}
},
"type": "special"
}
],
"max": 100,
"min": 0,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "rgba(50, 172, 45, 0.97)",
"value": null
},
{
"color": "rgba(237, 129, 40, 0.89)",
"value": 80
},
{
"color": "rgba(245, 54, 54, 0.9)",
"value": 95
}
]
},
"unit": "percent"
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 7,
"x": 8,
"y": 9
},
"hideTimeOverride": true,
"id": 11,
"links": [],
"maxDataPoints": 100,
"options": {
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"expr": "sum(100 * (redis_memory_used_bytes{instance=~\"$instance\"} / redis_memory_max_bytes{instance=~\"$instance\"}))",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "",
"metric": "",
"refId": "A",
"step": 2
}
],
"timeFrom": "1m",
"title": "内存使用情况",
"type": "gauge"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": [
{
"options": {
"0": {
"color": "dark-red",
"index": 0
}
},
"type": "value"
}
]
},
"overrides": []
},
"gridPos": {
"h": 7,
"w": 6,
"x": 15,
"y": 9
},
"id": 36,
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"exemplar": false,
"expr": "up{job_name=~\"\",namespace!=\"\"} !=1",
"instant": false,
"interval": "1s",
"legendFormat": "{{namespace}} {{instance}}",
"range": true,
"refId": "A"
}
],
"title": "目标 Redis 是否可达",
"transparent": true,
"type": "piechart"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "dark-blue",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 3,
"x": 21,
"y": 9
},
"id": 30,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"text": {
"valueSize": 40
},
"textMode": "name"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "count by (redis_version) (redis_instance_info{instance=~\"$instance\", namespace=~\"$namespace\"})",
"legendFormat": "{{redis_version}}",
"range": true,
"refId": "A"
}
],
"title": "版本号",
"type": "stat"
},
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "dark-blue",
"value": null
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 4,
"w": 3,
"x": 21,
"y": 12
},
"id": 32,
"options": {
"colorMode": "background",
"graphMode": "none",
"justifyMode": "center",
"orientation": "auto",
"reduceOptions": {
"calcs": [],
"fields": "",
"values": false
},
"text": {
"valueSize": 30
},
"textMode": "name"
},
"pluginVersion": "8.5.2",
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "count by (maxmemory_policy) (redis_instance_info{instance=~\"$instance\", namespace=~\"$namespace\"})",
"legendFormat": "{{maxmemory_policy}}",
"range": true,
"refId": "A"
}
],
"title": "驱逐策略",
"type": "stat"
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 8,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 16
},
"hiddenSeries": false,
"id": 18,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": false,
"max": false,
"min": false,
"show": false,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editorMode": "code",
"expr": "sum(rate(redis_commands_total{instance=~\"$instance\"} [1m])) by (cmd)",
"format": "time_series",
"interval": "1s",
"intervalFactor": 2,
"legendFormat": "{{ cmd }}",
"metric": "redis_command_calls_total",
"range": true,
"refId": "A",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "命令总数/秒",
"tooltip": {
"msResolution": true,
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"decimals": 2,
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 16
},
"hiddenSeries": false,
"id": 1,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": false,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": true,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "irate(redis_keyspace_hits_total{instance=~\"$instance\"}[5m])",
"format": "time_series",
"hide": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "hits, {{ instance }}",
"metric": "",
"refId": "A",
"step": 240,
"target": ""
},
{
"expr": "irate(redis_keyspace_misses_total{instance=~\"$instance\"}[5m])",
"format": "time_series",
"hide": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "misses, {{ instance }}",
"metric": "",
"refId": "B",
"step": 240,
"target": ""
}
],
"thresholds": [],
"timeRegions": [],
"title": "每秒命中/未命中",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": "",
"logBase": 1,
"min": 0,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {
"max": "#BF1B00"
},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 23
},
"hiddenSeries": false,
"id": 7,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "null as zero",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "redis_memory_used_bytes{instance=~\"$instance\"}",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "used, {{ instance }}",
"metric": "",
"refId": "A",
"step": 240,
"target": ""
},
{
"expr": "redis_memory_max_bytes{instance=~\"$instance\"}",
"format": "time_series",
"hide": false,
"intervalFactor": 2,
"legendFormat": "max, {{ instance }}",
"refId": "B",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "总内存使用量",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "bytes",
"logBase": 1,
"min": 0,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 23
},
"hiddenSeries": false,
"id": 10,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(redis_net_input_bytes_total{instance=~\"$instance\"}[5m]))",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{ input }}",
"refId": "A",
"step": 240
},
{
"expr": "sum(rate(redis_net_output_bytes_total{instance=~\"$instance\"}[5m]))",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ output }}",
"refId": "B",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "网络 I/O",
"tooltip": {
"msResolution": true,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "bytes",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 7,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 30
},
"hiddenSeries": false,
"id": 5,
"isNew": true,
"legend": {
"alignAsTable": false,
"avg": false,
"current": true,
"hideEmpty": false,
"hideZero": true,
"max": false,
"min": false,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum (redis_db_keys{instance=~\"$instance\"}) by (db, instance)",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ db }}, {{ instance }}",
"refId": "A",
"step": 240,
"target": ""
}
],
"thresholds": [],
"timeRegions": [],
"title": "每个数据库的项目总数",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "none",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 7,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 30
},
"hiddenSeries": false,
"id": 13,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum (redis_db_keys{instance=~\"$instance\"}) by (instance) - sum (redis_db_keys_expiring{instance=~\"$instance\"}) by (instance)",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "not expiring, {{ instance }}",
"refId": "A",
"step": 240,
"target": ""
},
{
"expr": "sum (redis_db_keys_expiring{instance=~\"$instance\"}) by (instance)",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "expiring, {{ instance }}",
"metric": "",
"refId": "B",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "即将过期的密钥与未过期的密钥",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {
"evicts": "#890F02",
"memcached_items_evicted_total{instance=\"172.17.0.1:9150\",job=\"prometheus\"}": "#890F02",
"reclaims": "#3F6833"
},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 37
},
"hiddenSeries": false,
"id": 8,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [
{
"alias": "reclaims",
"yaxis": 2
}
],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(rate(redis_expired_keys_total{instance=~\"$instance\"}[5m])) by (instance)",
"format": "time_series",
"hide": false,
"interval": "",
"intervalFactor": 2,
"legendFormat": "expired, {{ instance }}",
"metric": "",
"refId": "A",
"step": 240,
"target": ""
},
{
"expr": "sum(rate(redis_evicted_keys_total{instance=~\"$instance\"}[5m])) by (instance)",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "evicted, {{ instance }}",
"refId": "B",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "过期/逐出的密钥",
"tooltip": {
"msResolution": false,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 37
},
"hiddenSeries": false,
"id": 16,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(redis_connected_clients{instance=~\"$instance\"})",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "connected",
"refId": "A"
},
{
"expr": "sum(redis_blocked_clients{instance=~\"$instance\"})",
"format": "time_series",
"intervalFactor": 1,
"legendFormat": "blocked",
"refId": "B"
}
],
"thresholds": [],
"timeRegions": [],
"title": "已连接/阻止的客户端",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 2,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 0,
"y": 44
},
"hiddenSeries": false,
"id": 20,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": true,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(irate(redis_commands_duration_seconds_total{instance =~ \"$instance\"}[1m])) by (cmd)\n /\nsum(irate(redis_commands_total{instance =~ \"$instance\"}[1m])) by (cmd)\n",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ cmd }}",
"metric": "redis_command_calls_total",
"refId": "A",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "命令/秒的平均花费时间",
"tooltip": {
"msResolution": true,
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "s",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"editable": true,
"error": false,
"fieldConfig": {
"defaults": {
"links": []
},
"overrides": []
},
"fill": 8,
"fillGradient": 0,
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 44
},
"hiddenSeries": false,
"id": 14,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "connected",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "8.5.2",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": true,
"steppedLine": false,
"targets": [
{
"expr": "sum(irate(redis_commands_duration_seconds_total{instance=~\"$instance\"}[1m])) by (cmd) != 0",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
"legendFormat": "{{ cmd }}",
"metric": "redis_command_calls_total",
"refId": "A",
"step": 240
}
],
"thresholds": [],
"timeRegions": [],
"title": "命令所花费的总时间/秒",
"tooltip": {
"msResolution": true,
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"show": true,
"values": []
},
"yaxes": [
{
"format": "s",
"logBase": 1,
"show": true
},
{
"format": "short",
"logBase": 1,
"show": true
}
],
"yaxis": {
"align": false
}
}
],
"refresh": "5s",
"schemaVersion": 36,
"style": "dark",
"tags": [
"prometheus",
"redis"
],
"templating": {
"list": [
{
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"definition": "label_values(redis_up, namespace)",
"hide": 0,
"includeAll": false,
"multi": false,
"name": "namespace",
"options": [],
"query": {
"query": "label_values(redis_up, namespace)",
"refId": "Prometheus-namespace-Variable-Query"
},
"refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"current": {},
"datasource": {
"type": "prometheus",
"uid": "${DS_业务}"
},
"definition": "label_values(redis_up{namespace=~\"$namespace\"}, instance)",
"hide": 0,
"includeAll": false,
"multi": true,
"name": "instance",
"options": [],
"query": {
"query": "label_values(redis_up{namespace=~\"$namespace\"}, instance)",
"refId": "Prometheus-instance-Variable-Query"
},
"refresh": 2,
"regex": "",
"skipUrlSync": false,
"sort": 1,
"tagValuesQuery": "",
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-1m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "browser",
"title": "业务",
"uid": "1",
"version": 46,
"weekStart": ""
}
配置 Prometheus 命名空间进行分组管理
修改自定义面板 PromQL 语句
cd /usr/local/prometheus/prometheus-2.45.2/redis_exporter_conf
vim text_A_redis_cluaster.json
[
{
"targets": [ "redis://50.50.50.100:7000",
"redis://50.50.50.100:7001",
"redis://50.50.50.100:7002",
"redis://50.50.50.100:7003",
"redis://50.50.50.100:7004",
"redis://50.50.50.100:7005" ],
"labels": {"namespace": "text_A_cluaster"}
}
]
vim text_B_redis_sentinel.json
[
{
"targets": [ "redis://50.50.50.100:6379",
"redis://50.50.50.100:6380",
"redis://50.50.50.100:6381" ],
"labels": {"namespace": "text_B_sentinel"}
}
]
修改 master slave link 面板查询语句
redis_master_link_up{instance=~"$instance", namespace=~"$namespace"}
redis_connected_slave_lag_seconds{instance=~"$instance", namespace=~"$namespace"}
部署 grafana 用于展示和可视化监控数据,它提供了一个直观的用户界面,可以通过仪表盘和图表来展示从 prometheus 收集到的数据
https://grafana.com/grafana/download?pg=graf&plcmt=deploy-box-1
grafana-enterprise-8.5.2-1.x86_64.rpm
yum install -y grafana-enterprise-8.5.2-1.x86_64.rpm
systemctl start grafana-server.service
systemctl enable grafana-server.service
http://50.50.50.100:3000/
安装 redis 数据源插件用于将 redis 中的数据可视化展示为各种图表和仪表盘
https://grafana.com/grafana/plugins/redis-datasource/?tab=installation
grafana-cli plugins install redis-datasource # 使用 grafana-cli 工具从命令行安装 redis
配置都差不多,我这里就只添加个 redis 集群 的监控了
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。