redis集群监控

article/2025/8/14 9:25:32

通过Prometheus监控redis集群

一、promethus安装

下载地址:

https://github.com/prometheus/prometheus/releases

1、下载

wget https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz

2、安装、配置

tar -zxvf prometheus-2.32.1.linux-amd64.tar.gz -C /usr/local/

3、编写systemctl启动脚本

vim /usr/lib/systemd/system/prometheus.service 
[Unit]
Description=Prometheus Node Exporter
After=network.target[Service]
ExecStart=/usr/local/prometheus-2.32.1.linux-amd64/prometheus --config.file=/usr/local/prometheus-2.32.1.linux-amd64/prometheus.yml --web.read-timeout=5m  --web.max-connections=10 --storage.tsdb.retention=15d --storage.tsdb.path=/usr/local/prometheus-2.32.1.linux-amd64/data --query.max-concurrency=20 --query.timeout=2m
User=root
[Install]
WantedBy=multi-user.target

启动参数说明:

–config.file=/etc/prometheus.yml 指定配置文件–web.read-timeout=5m 请求链接的最大等待时间,防止太多的空闲链接占用资源–web.max-connections=512 针对prometheus,获取数据源的时候,建立的网络链接数,做一个最大数字的限制,防止链接数过多造成资源过大的消耗–storage.tsdb.retention=15d 重要参数,prometheus 开始采集监控数据后,会存在内存和硬盘中;对于保存期限的设置。时间过长,硬盘和内存都吃不消;时间太短,要查历史数据就没了。企业15天最为合适。–storage.tsdb.path="/prometheus/data" 存储数据路径,不要随便定义–query.max-concurrency=20 用户查询最大并发数–query.timeout=2m 慢查询强制终止

4、启动

# 重载配置
systemctl daemon-reload#设置开机自启动
systemctl enable prometheus#启动
systemctl start prometheus查看启动状态
systemctl status prometheus

Prometheus内置了一个web界面,我们可通过http://ip:9090进行访问

二 、搭建redis_exporter 

1、下载https://github.com/oliver006/redis_exporter/releases/download/v1.39.0/redis_exporter-v1.39.0.linux-amd64.tar.gz

2、解压

tar -zxvf redis_exporter-v1.39.0.linux-amd64.tar.gz -C /usr/local/

3、创建启动脚本

cd  /usr/local/redis_exporter-v1.39.0.linux-amd64

mkdir bin

cd bin 

vim start.sh

#!/bin/bash
workhome=$(cd $(dirname $0)/../; pwd)
nohup ${workhome}/redis_exporter -redis.password pwd888 -web.listen-address 0.0.0.0:9122 &

chmod 777 start.sh

 4、启动服务

/usr/local/redis_exporter-v1.39.0.linux-amd64/bin/start.sh

 5、在prometheus.yml中加入job

vim /usr/local/prometheus-2.32.1.linux-amd64/prometheus.yml ,添加如下信息

  - job_name: 'redis_exporter_targets'static_configs:- targets:- redis://localhost:9001- redis://localhost:9002- redis://localhost:9003- redis://localhost:9004- redis://localhost:9005- redis://localhost:9006params:check-keys: ["metrics:*"]metrics_path: /scraperelabel_configs:- source_labels: [__address__]target_label: __param_target- source_labels: [__param_target]target_label: instance- target_label: __address__replacement: 172.128.81.16:9122- job_name: 'redis_exporter'static_configs:- targets:- 172.128.81.16:9122

 重启后,可以看到redis集群的状态均为UP

 

如果有安装granfana的,可以通过grafana对应的redis模板监控

使用如下模板

{  "annotations": {    "list": [      {        "builtIn": 1,        "datasource": "-- Grafana --",        "enable": true,        "hide": true,        "iconColor": "rgba(0, 211, 255, 1)",        "name": "Annotations & Alerts",        "type": "dashboard"      }    ]  },  "editable": true,  "gnetId": null,  "graphTooltip": 0,  "id": 12,  "iteration": 1597660467403,  "links": [],  "panels": [    {      "cacheTimeout": null,      "colorBackground": false,      "colorValue": true,      "colors": [        "#299c46",        "rgba(237, 129, 40, 0.89)",        "#d44a3a"      ],      "datasource": null,      "description": "redis集群节点数",      "fieldConfig": {        "defaults": {          "custom": {}        },        "overrides": []      },      "format": "none",      "gauge": {        "maxValue": 100,        "minValue": 0,        "show": false,        "thresholdLabels": false,        "thresholdMarkers": true      },      "gridPos": {        "h": 2,        "w": 2,        "x": 0,        "y": 0      },      "id": 36,      "interval": null,      "links": [],      "mappingType": 1,      "mappingTypes": [        {          "name": "value to text",          "value": 1        },        {          "name": "range to text",          "value": 2        }      ],      "maxDataPoints": 100,      "nullPointMode": "connected",      "nullText": null,      "postfix": "",      "postfixFontSize": "50%",      "prefix": "",      "prefixFontSize": "50%",      "rangeMaps": [        {          "from": "null",          "text": "N/A",          "to": "null"        }      ],      "sparkline": {        "fillColor": "rgba(31, 118, 189, 0.18)",        "full": false,        "lineColor": "rgb(31, 120, 193)",        "show": false,        "ymax": null,        "ymin": null      },      "tableColumn": "",      "targets": [        {          "expr": "count(redis_instance_info{job=~\"$rediscluster\"})",          "interval": "",          "legendFormat": "",          "refId": "A"        }      ],      "thresholds": "",      "timeFrom": null,      "timeShift": null,      "title": "redis集群节点数",      "type": "singlestat",      "valueFontSize": "100%",      "valueMaps": [        {          "op": "=",          "text": "N/A",          "value": "null"        }      ],      "valueName": "current"    },    {      "cacheTimeout": null,      "colorBackground": false,      "colorValue": true,      "colors": [        "#299c46",        "rgba(237, 129, 40, 0.89)",        "#d44a3a"      ],      "datasource": null,      "description": "集群活跃节点数量",      "fieldConfig": {        "defaults": {          "custom": {}        },        "overrides": []      },      "format": "none",      "gauge": {        "maxValue": 100,        "minValue": 0,        "show": false,        "thresholdLabels": false,        "thresholdMarkers": true      },      "gridPos": {        "h": 2,        "w": 2,        "x": 2,        "y": 0      },      "id": 37,      "interval": null,      "links": [],      "mappingType": 1,      "mappingTypes": [        {          "name": "value to text",          "value": 1        },        {          "name": "range to text",          "value": 2        }      ],      "maxDataPoints": 100,      "nullPointMode": "connected",      "nullText": null,      "postfix": "",      "postfixFontSize": "50%",      "prefix": "",      "prefixFontSize": "50%",      "rangeMaps": [        {          "from": "null",          "text": "N/A",          "to": "null"        }      ],      "sparkline": {        "fillColor": "rgba(31, 118, 189, 0.18)",        "full": false,        "lineColor": "rgb(31, 120, 193)",        "show": false,        "ymax": null,        "ymin": null      },      "tableColumn": "",      "targets": [        {          "expr": "count(redis_up{job=~\"$rediscluster\"}>0)",          "interval": "",          "legendFormat": "",          "refId": "A"        }      ],      "thresholds": "",      "timeFrom": null,      "timeShift": null,      "title": "集群活跃节点数",      "type": "singlestat",      "valueFontSize": "100%",      "valueMaps": [        {          "op": "=",          "text": "N/A",          "value": "null"        }      ],      "valueName": "current"    },    {      "cacheTimeout": null,      "colorBackground": false,      "colorValue": true,      "colors": [        "#299c46",        "rgba(237, 129, 40, 0.89)",        "#d44a3a"      ],      "datasource": null,      "description": "从节点数量",      "fieldConfig": {        "defaults": {          "custom": {}        },        "overrides": []      },      "format": "none",      "gauge": {        "maxValue": 100,        "minValue": 0,        "show": false,        "thresholdLabels": false,        "thresholdMarkers": true      },      "gridPos": {        "h": 2,        "w": 2,        "x": 4,        "y": 0      },      "id": 12,      "interval": null,      "links": [],      "mappingType": 1,      "mappingTypes": [        {          "name": "value to text",          "value": 1        },        {          "name": "range to text",          "value": 2        }      ],      "maxDataPoints": 100,      "nullPointMode": "connected",      "nullText": null,      "postfix": "",      "postfixFontSize": "50%",      "prefix": "",      "prefixFontSize": "50%",      "rangeMaps": [        {          "from": "null",          "text": "N/A",          "to": "null"        }      ],      "sparkline": {        "fillColor": "rgba(31, 118, 189, 0.18)",        "full": false,        "lineColor": "rgb(31, 120, 193)",        "show": false,        "ymax": null,        "ymin": null      },      "tableColumn": "",      "targets": [        {          "expr": "count(redis_instance_info{job=~\"$rediscluster\", role=\"slave\"})",          "interval": "",          "legendFormat": "",          "refId": "A"        }      ],      "thresholds": "",      "timeFrom": null,      "timeShift": null,      "title": "从节点个数",      "type": "singlestat",      "valueFontSize": "100%",      "valueMaps": [        {          "op": "=",          "text": "N/A",          "value": "null"        }      ],      "valueName": "current"    },    {      "cacheTimeout": null,      "colorBackground": false,      "colorPrefix": false,      "colorValue": true,      "colors": [        "#299c46",        "rgba(237, 129, 40, 0.89)",        "#d44a3a"      ],      "datasource": null,      "description": "主节点数量",      "fieldConfig": {        "defaults": {          "custom": {}        },        "overrides": []      },      "format": "none",      "gauge": {        "maxValue": 100,        "minValue": 0,        "show": false,        "thresholdLabels": false,        "thresholdMarkers": true      },      "gridPos": {        "h": 2,        "w": 2,        "x": 6,        "y": 0      },      "id": 10,      "interval": null,      "links": [],      "mappingType": 1,      "mappingTypes": [        {          "name": "value to text",          "value": 1        },        {          "name": "range to text",          "value": 2        }      ],      "maxDataPoints": 100,      "nullPointMode": "connected",      "nullText": null,      "postfix": "",      "postfixFontSize": "50%",      "prefix": "",      "prefixFontSize": "50%",      "rangeMaps": [        {          "from": "null",          "text": "N/A",          "to": "null"        }      ],      "sparkline": {        "fillColor": "rgba(31, 118, 189, 0.18)",        "full": false,        "lineColor": "rgb(31, 120, 193)",        "show": false,        "ymax": null,        "ymin": null      },      "tableColumn": "",      "targets": [        {          "expr": "count(redis_instance_info{job=~\"$rediscluster\", role=\"master\"})",          "interval": "",          "legendFormat": "",          "refId": "A"        }      ],      "thresholds": "",      "timeFrom": null,      "timeShift": null,      "title": "主节点个数",      "type": "singlestat",      "valueFontSize": "100%",      "valueMaps": [        {          "op": "=",          "text": "N/A",          "value": "null"        }      ],      "valueName": "current"    },    {      "datasource": null,      "description": "Redis 内存使用大小值",      "fieldConfig": {        "defaults": {          "custom": {},          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              }            ]          },          "unit": "decbytes"        },        "overrides": []      },      "gridPos": {        "h": 8,        "w": 3,        "x": 8,        "y": 0      },      "id": 18,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "sum(redis_memory_used_bytes{job=~\"$rediscluster\"})",          "interval": "5s",          "legendFormat": "{{addr}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "Redis 内存使用总量",      "type": "stat"    },    {      "datasource": null,      "description": "Redis 内存使用大小值",      "fieldConfig": {        "defaults": {          "custom": {},          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "#EAB839",                "value": 60              },              {                "color": "red",                "value": 80              }            ]          },          "unit": "percent"        },        "overrides": []      },      "gridPos": {        "h": 8,        "w": 3,        "x": 11,        "y": 0      },      "id": 47,      "options": {        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "showThresholdLabels": false,        "showThresholdMarkers": true      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "sum(redis_memory_used_bytes{job=~\"$rediscluster\"}) / sum(redis_config_maxmemory{job=~\"$rediscluster\"}) * 100",          "interval": "5s",          "legendFormat": "{{addr}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "Redis 内存使用总量百分比",      "type": "gauge"    },    {      "datasource": null,      "description": "Redis 内存使用率",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "max": 100,          "thresholds": {            "mode": "percentage",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "yellow",                "value": 60              },              {                "color": "red",                "value": 80              }            ]          },          "unit": "percent"        },        "overrides": []      },      "gridPos": {        "h": 17,        "w": 5,        "x": 14,        "y": 0      },      "id": 20,      "maxPerRow": 4,      "options": {        "displayMode": "gradient",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "showUnfilled": true      },      "pluginVersion": "7.1.3",      "repeat": null,      "repeatDirection": "h",      "targets": [        {          "expr": "(redis_memory_used_bytes{job=~\"$rediscluster\"} / redis_config_maxmemory{job=~\"$rediscluster\"}) * 100",          "interval": "5s",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "Redis 内存使用率/every nodes",      "type": "bargauge"    },    {      "cacheTimeout": null,      "datasource": null,      "description": "启动时间(天)",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "mappings": [            {              "id": 0,              "op": "=",              "text": "N/A",              "type": 1,              "value": "null"            }          ],          "nullValueMode": "connected",          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "#EAB839",                "value": 365              }            ]          },          "unit": "short"        },        "overrides": []      },      "gridPos": {        "h": 17,        "w": 5,        "x": 19,        "y": 0      },      "id": 42,      "interval": null,      "links": [],      "maxDataPoints": 100,      "options": {        "displayMode": "gradient",        "orientation": "horizontal",        "reduceOptions": {          "calcs": [            "lastNotNull"          ],          "fields": "",          "values": false        },        "showUnfilled": true      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "redis_uptime_in_seconds{job=~\"$rediscluster\"}/60/60/24",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "启动时间(天)",      "transparent": true,      "type": "bargauge"    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "Redis 内存使用大小值",      "fieldConfig": {        "defaults": {          "custom": {},          "links": []        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 6,        "w": 8,        "x": 0,        "y": 2      },      "hiddenSeries": false,      "id": 39,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": false,        "min": false,        "rightSide": true,        "show": true,        "sort": "current",        "sortDesc": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "redis_memory_used_bytes{job=~\"$rediscluster\"} ",          "interval": "5s",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "已用内存/every nodes",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "bytes",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "decimals": null,          "format": "short",          "label": "",          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "各个节点内存碎片率",      "fieldConfig": {        "defaults": {          "custom": {},          "links": []        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 9,        "w": 6,        "x": 0,        "y": 8      },      "hiddenSeries": false,      "id": 28,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": false,        "min": false,        "rightSide": true,        "show": true,        "sort": "current",        "sortDesc": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "redis_mem_fragmentation_ratio{job=~\"$rediscluster\"}",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "内存碎片率/every nodes",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "datasource": null,      "description": "各个节点内存碎片率",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "#EAB839",                "value": 1              },              {                "color": "red",                "value": 5              }            ]          }        },        "overrides": []      },      "gridPos": {        "h": 9,        "w": 8,        "x": 6,        "y": 8      },      "id": 50,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "delta(redis_slowlog_last_id{job=~\"$rediscluster\"}[5m]) ",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "每个节点慢日志 every 5min",      "type": "stat"    },    {      "datasource": null,      "description": "Redus  Cluster OPS指标",      "fieldConfig": {        "defaults": {          "custom": {},          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              }            ]          }        },        "overrides": []      },      "gridPos": {        "h": 5,        "w": 6,        "x": 0,        "y": 17      },      "id": 16,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "sum(irate(redis_commands_processed_total{job=~\"$rediscluster\"}[1m]))",          "format": "time_series",          "instant": false,          "interval": "5s",          "legendFormat": "{{alias}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "QPS total",      "type": "stat"    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "Redus  Cluster OPS指标",      "fieldConfig": {        "defaults": {          "custom": {},          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "red",                "value": 80              }            ]          }        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 5,        "w": 9,        "x": 6,        "y": 17      },      "hiddenSeries": false,      "id": 38,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": true,        "min": false,        "rightSide": true,        "show": true,        "sort": "current",        "sortDesc": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "irate(redis_commands_processed_total{job=~\"$rediscluster\"}[1m])",          "format": "time_series",          "instant": false,          "interval": "5s",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "QPS /every nodes",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "Command Calls / sec",      "fieldConfig": {        "defaults": {          "custom": {},          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "red",                "value": 80              }            ]          }        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 5,        "w": 9,        "x": 15,        "y": 17      },      "hiddenSeries": false,      "id": 46,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": false,        "min": false,        "rightSide": true,        "show": true,        "sort": "current",        "sortDesc": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "topk(10, irate(redis_commands_total{job=~\"$rediscluster\"} [5m]))",          "format": "time_series",          "instant": false,          "interval": "5s",          "legendFormat": "{{instance}} {{ cmd }}",          "refId": "A"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "Command Calls / sec",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "datasource": null,      "description": "各个节点活跃连接数",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              }            ]          }        },        "overrides": []      },      "gridPos": {        "h": 5,        "w": 6,        "x": 0,        "y": 22      },      "id": 49,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "sum(redis_connected_clients{job=~\"$rediscluster\"})",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "当前连接总数",      "type": "stat"    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "各个节点活跃连接数",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "red",                "value": 80              }            ]          }        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 5,        "w": 10,        "x": 6,        "y": 22      },      "hiddenSeries": false,      "id": 26,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": true,        "min": false,        "rightSide": true,        "show": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "redis_connected_clients{job=~\"$rediscluster\"}",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "client every nodes",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "Network I/O",      "fieldConfig": {        "defaults": {          "custom": {},          "links": []        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 5,        "w": 8,        "x": 16,        "y": 22      },      "hiddenSeries": false,      "id": 45,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": true,        "min": false,        "rightSide": true,        "show": true,        "sort": "current",        "sortDesc": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "rate(redis_net_input_bytes_total{job=~\"$rediscluster\"}[5m])",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        },        {          "expr": "rate(redis_net_output_bytes_total{job=~\"$rediscluster\"}[5m])",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "B"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "Network I/O",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "bytes",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "datasource": null,      "description": "",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              }            ]          }        },        "overrides": []      },      "gridPos": {        "h": 6,        "w": 8,        "x": 0,        "y": 27      },      "id": 22,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "sum(redis_db_keys{job=~\"$rediscluster\"})",          "format": "time_series",          "interval": "",          "intervalFactor": 1,          "legendFormat": "total key",          "refId": "A"        },        {          "expr": "sum (redis_db_keys{job=~\"$rediscluster\"}) - sum (redis_db_keys_expiring{job=~\"$rediscluster\"}) ",          "format": "time_series",          "interval": "",          "intervalFactor": 1,          "legendFormat": "no expir key",          "refId": "B"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "total keys",      "type": "stat"    },    {      "datasource": null,      "description": "",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "yellow",                "value": 70              },              {                "color": "dark-red",                "value": 90              }            ]          },          "unit": "percent"        },        "overrides": []      },      "gridPos": {        "h": 6,        "w": 3,        "x": 8,        "y": 27      },      "id": 48,      "options": {        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "showThresholdLabels": false,        "showThresholdMarkers": true      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "100-((sum (redis_db_keys_expiring{job=~\"$rediscluster\"})  /sum (redis_db_keys{job=~\"$rediscluster\"}))*100)",          "format": "time_series",          "interval": "",          "intervalFactor": 1,          "legendFormat": "",          "refId": "B"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "未设置过期时间key百分比",      "type": "gauge"    },    {      "aliasColors": {},      "bars": false,      "dashLength": 10,      "dashes": false,      "datasource": null,      "description": "各个节点以及集群的 KEYS 总数",      "fieldConfig": {        "defaults": {          "custom": {},          "links": []        },        "overrides": []      },      "fill": 1,      "fillGradient": 0,      "gridPos": {        "h": 6,        "w": 13,        "x": 11,        "y": 27      },      "hiddenSeries": false,      "id": 41,      "legend": {        "alignAsTable": true,        "avg": false,        "current": true,        "max": false,        "min": false,        "rightSide": true,        "show": true,        "sort": "current",        "sortDesc": true,        "total": false,        "values": true      },      "lines": true,      "linewidth": 1,      "nullPointMode": "null",      "percentage": false,      "pluginVersion": "7.1.3",      "pointradius": 2,      "points": false,      "renderer": "flot",      "seriesOverrides": [],      "spaceLength": 10,      "stack": false,      "steppedLine": false,      "targets": [        {          "expr": "redis_db_keys{job=~\"$rediscluster\"}",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "thresholds": [],      "timeFrom": null,      "timeRegions": [],      "timeShift": null,      "title": "KEYS 每节点",      "tooltip": {        "shared": true,        "sort": 0,        "value_type": "individual"      },      "type": "graph",      "xaxis": {        "buckets": null,        "mode": "time",        "name": null,        "show": true,        "values": []      },      "yaxes": [        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        },        {          "format": "short",          "label": null,          "logBase": 1,          "max": null,          "min": null,          "show": true        }      ],      "yaxis": {        "align": false,        "alignLevel": null      }    },    {      "datasource": null,      "description": "Hitsper Sec",      "fieldConfig": {        "defaults": {          "custom": {            "align": null          },          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              }            ]          }        },        "overrides": []      },      "gridPos": {        "h": 10,        "w": 24,        "x": 0,        "y": 33      },      "id": 43,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "irate(redis_keyspace_hits_total{job=~\"$rediscluster\"}[5m])",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "Hitsper Sec",      "type": "stat"    },    {      "datasource": null,      "description": "Hits / Misses per Sec",      "fieldConfig": {        "defaults": {          "custom": {},          "links": [],          "mappings": [],          "thresholds": {            "mode": "absolute",            "steps": [              {                "color": "green",                "value": null              },              {                "color": "#EAB839",                "value": 80              },              {                "color": "red",                "value": 200              }            ]          }        },        "overrides": []      },      "gridPos": {        "h": 11,        "w": 24,        "x": 0,        "y": 43      },      "id": 44,      "options": {        "colorMode": "value",        "graphMode": "area",        "justifyMode": "auto",        "orientation": "auto",        "reduceOptions": {          "calcs": [            "mean"          ],          "fields": "",          "values": false        },        "textMode": "auto"      },      "pluginVersion": "7.1.3",      "targets": [        {          "expr": "irate(redis_keyspace_misses_total{job=~\"$rediscluster\"}[5m])",          "interval": "",          "legendFormat": "{{instance}}",          "refId": "A"        }      ],      "timeFrom": null,      "timeShift": null,      "title": "Misses per Sec",      "type": "stat"    }  ],  "refresh": false,  "schemaVersion": 26,  "style": "dark",  "tags": [],  "templating": {    "list": [      {        "allValue": null,        "current": {          "selected": true,          "text": "All",          "value": [            "$__all"          ]        },        "datasource": "Prometheus",        "definition": "label_values(redis_instance_info{job=~\"$rediscluster\"},role)",        "hide": 0,        "includeAll": true,        "label": "Role",        "multi": true,        "name": "role",        "options": [],        "query": "label_values(redis_instance_info{job=~\"$rediscluster\"},role)",        "refresh": 1,        "regex": "",        "skipUrlSync": false,        "sort": 0,        "tagValuesQuery": "",        "tags": [],        "tagsQuery": "",        "type": "query",        "useTags": false      },      {        "allValue": null,        "current": {          "selected": true,          "text": "All",          "value": [            "$__all"          ]        },        "datasource": "Prometheus",        "definition": "label_values(redis_instance_info{alias=~\"$cluster\",role=~\"$role\"},addr)",        "hide": 2,        "includeAll": true,        "label": "instance",        "multi": true,        "name": "instance",        "options": [],        "query": "label_values(redis_instance_info{alias=~\"$cluster\",role=~\"$role\"},addr)",        "refresh": 1,        "regex": "",        "skipUrlSync": false,        "sort": 0,        "tagValuesQuery": "",        "tags": [],        "tagsQuery": "",        "type": "query",        "useTags": false      },      {        "allValue": null,        "current": {          "selected": true,          "text": "All",          "value": [            "$__all"          ]        },        "datasource": "Prometheus",        "definition": "label_values(redis_instance_info{job=~\"$rediscluster\",role=\"master\"},addr)",        "hide": 2,        "includeAll": true,        "label": "master",        "multi": true,        "name": "master",        "options": [],        "query": "label_values(redis_instance_info{job=~\"$rediscluster\",role=\"master\"},addr)",        "refresh": 1,        "regex": "",        "skipUrlSync": false,        "sort": 0,        "tagValuesQuery": "",        "tags": [],        "tagsQuery": "",        "type": "query",        "useTags": false      },      {        "allValue": null,        "current": {          "selected": true,          "text": "redis_exporter_targets-SIT-vm01",          "value": "redis_exporter_targets-SIT-vm01"        },        "datasource": "Prometheus",        "definition": "label_values(job)",        "hide": 0,        "includeAll": false,        "label": null,        "multi": false,        "name": "rediscluster",        "options": [          {            "selected": false,            "text": "redis_exporter_targets-DEV-vm01",            "value": "redis_exporter_targets-DEV-vm01"          },          {            "selected": false,            "text": "redis_exporter_targets-DEV-vm02",            "value": "redis_exporter_targets-DEV-vm02"          },          {            "selected": false,            "text": "redis_exporter_targets-DEV-vm03",            "value": "redis_exporter_targets-DEV-vm03"          },          {            "selected": false,            "text": "redis_exporter_targets-SIT-docker01",            "value": "redis_exporter_targets-SIT-docker01"          },          {            "selected": true,            "text": "redis_exporter_targets-SIT-vm01",            "value": "redis_exporter_targets-SIT-vm01"          },          {            "selected": false,            "text": "redis_exporter_targets-SIT01",            "value": "redis_exporter_targets-SIT01"          }        ],        "query": "label_values(job)",        "refresh": 0,        "regex": "",        "skipUrlSync": false,        "sort": 0,        "tagValuesQuery": "",        "tags": [],        "tagsQuery": "",        "type": "query",        "useTags": false      }    ]  },  "time": {    "from": "now-5m",    "to": "now"  },  "timepicker": {    "refresh_intervals": [      "5s",      "10s",      "30s",      "1m",      "5m",      "15m",      "30m",      "1h",      "2h",      "1d"    ]  },  "timezone": "",  "title": "Redis Cluster Monitor",  "uid": "rakSCeSMk",  "version": 82}

将上面模板 导入 

然后修改修改clusternode变量

 

 

 保存,即可查看整体监控效果

 

支持查看整体和每个集群的慢日志、QPS、内存使用率、客户端连接数、不通操作QPS、集群整体健康状况、网络IO、总key,未设置失效时间key、内存碎片、缓存命中/未命中数等。 


http://chatgpt.dhexx.cn/article/uPkjRHeN.shtml

相关文章

Linux安装Redis监控工具RedisInsight

文章目录 1.简介2.安装RedisInsight2.1下载RedisInsight2.2配置RedisInsight2.3运行RedisInsight 3.使用RedisInsight3.1添加Redis3.1.1添加单机Redis 3.2自动发现Redis3.3以编程方式添加Redis3.4性能指标3.5集群管理3.6命令行3.7内存分析3.7.1在实例上运行内存分析3.7.2内存概…

RedisInsight:Redis监控工具部署(linux)

RedisInsight 部署流程 简介一、下载二、安装1.准备工作2.配置及介绍3.运行4.访问 总结 简介 RedisInsight提供以下功能: 易于使用基于浏览器的界面来搜索键、查看和编辑数据唯一支持Redis集群的GUI工具支持基于SSL/TLS的连接运行内存分析 一、下载 下载地址: R…

redis监控工具

redis-monitor 项目github地址:https://github.com/NetEaseGame/redis-monitor (看作者名称,应该是华科的) # 安装 pip install redis-monitor#初始化redis-monitor init#启动 nohup redis-monitor start > redis-monitor.l…

Redis性能监控

redis_exporter prometheus grafana监控Redis服务指标 1.redis_exporter2.prometheus3.grafana 本文使用 redis_exporter prometheus grafana 实现对Redis服务进行监控,原因:成本低,人工干预少,直接下载对应的组件,只需添加配置即可互相通信,可视化指标也比较全面。 下面是在…

性能测试:Redis性能监控(redis-stat工具)

redis 监控 redis 监控一共有两种方式,一种是通过info命令,还有一种是使用redis-stat工具。两者其实本质是一样的,不过一个是命令行的模式下查看监控数据,而另外一种是图形化页面查看。但是实际上,我们性能测试主要更…

Redis监控利器---Redis State

强烈推荐一个大神的人工智能的教程:http://www.captainai.net/zhanghan 【前言】 在之前的博文《Redis百万级别数据迁移》中分享我们系统为降低服务器成本,从亚马逊云迁至阿里云的一次生产迁移过程中Redis部分迁移;去年迁移Redis时数据量500…

【Redis监控】

方法1:redis-stat 下载地址:https://github.com/junegunn/redis-stat 可以直接下载安装jar包 Usage usage: redis-stat [HOST[:PORT][/PASS] ...] [INTERVAL [COUNT]] -a, --authPASSWORD Password -v, --verbose …

redis监控

上篇我们将redis安装好了,但是自己搭建的服务监控起来比较麻烦,我们每次都需要跑到redis-cli使用info命令查看redis的状态。 所以我们需要一个可视化的redis监控工具,这里我们为了方便使用docker进行安装,毕竟依赖这个东西是要搞…

性能测试之Redis和Nginx 性能监控

redis 监控 redis 监控一共有两种方式,一种是通过info命令,还有一种是使用redis-stat工具。两者其实本质是一样的,不过一个是命令行的模式下查看监控数据,而另外一种是图形化页面查看。但是实际上,我们性能测试主要更…

redis基础监控

redis监控 redis server 监控: redis存活判断:ping判断,如果指定时间返回PONG表示存活,否则redis不能响应请求,可能阻塞或死亡 机器端口检查:nc 判断端口是否正常。 连接数:connected_clients …

【23种设计模式】设计模式介绍与分类

前言 本文为 【23种设计模式】设计模式介绍与分类 相关知识介绍,下边将对什么是设计模式,设计模式的分类与23种设计模式的关键点进行详尽介绍~ 📌博主主页:小新要变强 的主页 👉Java全栈学习路线可参考:【…

Java之美[从菜鸟到高手演变]之设计模式

设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可…

23 种设计模式详解(全23种)

设计模式的分类 总体来说设计模式分为三大类: 创建型模式,共五种:工厂方法模式、抽象工厂模式、单例模式、建造者模式、原型模式。 结构型模式,共七种:适配器模式、装饰器模式、代理模式、外观模式、桥接模式、组合…

23种设计模式汇总整理

设计模式分为三大类: 创建型模式,共五种:工厂方法模式、抽象工厂模式、单例模式、建造者模式、原型模式 结构型模式,共七种:适配器模式、装饰者模式、代理模式、外观模式、桥接模式、组合模式、享元模式。 行为型模…

设计模式的作用

这几天一边搞论文,一边学设计模式。真的是搞得我头昏脑胀,隐约明白设计模式是一种规范,一种体系。接到一个棘手或大型的项目,通过经验丰富或者领导的拆解,拆成一个个小的项目模块。然后让其他人去实现。会有一些约定俗…

设计模式概述 以及 23种设计模式的介绍

设计模式概述(Design pattern): 设计模式:代表了最佳的实践,通常被有经验的面向对象的软件开发人员所采用。设计模式是软件开发人员在软件开发过程中面临的一般问题的解决方案。这些解决方案是众多软件开发人员经过相…

设计模式(一)设计模式的分类与区别

文章目录 一、设计模式的六大原则1.1 开闭原则(总原则)1.2 里氏替换原则1.3 依赖倒置原则1.4 单一职责原则1.5 接口隔离原则1.6 迪米特法则1.7 合成复用原则 二、设计模式的三大类别2.1 创建型模式2.2 结构型模式2.3 行为型模式 三、设计模式的使用3.1 设…

Java中常用的设计模式

文章转载借鉴:http://blog.csdn.net/zhangerqing 一、什么是设计模式 设计模式(Design pattern)是一套被反复使用、多数人知晓的、经过分类编目的、代码设计经验的总结。使用设计模式是为了可重用代码、让代码更容易被他人理解、保证代码可…

23种设计模式概述

设计模式共有23种,创建型模式5种,结构型模式7种,行为型模式11种,本章只做概念性说明。 (一) 创建型模式 01 工厂模式 定义:又叫做静态工厂方法,定义一个用于创建对象的接口&#…

常用的几种设计模式详解

设计模式的概述 设计模式分类 创建型模式 特点是将对象的创建与使用分离(解耦),有 单例、原型、工厂方法、抽象工厂、建造者等5种。 结构型模式 用于描述如何将类或对象按某种布局组成更大的结构,代理、适配器、桥接、装饰、享元…