探索云原生监控:Redis的全新视角

发表时间: 2023-06-14 13:36


redis exporter介绍

Redis Exporter 是一个用于将 Redis 数据库的监控指标导出到 Prometheus 的工具。它可以查询 Redis 实例,获取 Redis 服务器的各种指标,例如内存使用情况、命中率、连接数等,并将这些指标以 Prometheus 格式的格式呈现出来,以便于 Prometheus 进行数据收集和监控。

Redis Exporter 可以作为一个独立的进程运行,也可以与 Redis 服务器一起运行在同一台机器上。它支持多种 Redis 版本,包括 Redis 2.x、Redis 3.x 和 Redis 4.x。除了标准的 Redis 指标之外,Redis Exporter 还提供了一些扩展指标,例如集群模式下的复制和分片指标等。

Redis Exporter 还支持多种部署方式,包括 Docker 容器、二进制文件、系统包等。它可以与 Prometheus 和 Grafana 等监控和可视化工具集成,帮助用户监控和分析 Redis 数据库的性能和健康状况。

总之,Redis Exporter 是一个非常有用的工具,可以帮助用户监控和优化 Redis 数据库的性能和可用性,提高业务的稳定性和可靠性。

redis exporter安装使用

  1. 下载和安装 Redis Exporter。

您可以从 Redis Exporter 的 GitHub 页面(
https://github.com/oliver006/redis_exporter)下载最新版本的二进制文件或使用 Docker 镜像来部署 Redis Exporter。

  1. 配置 Redis Exporter。

Redis Exporter 的配置文件是一个 YAML 格式的文件,包括 Redis 实例的连接信息、指标的采集频率、导出的指标名称等。您可以根据实际情况修改配置文件,以满足您的需求。

以下是一个简单的 Redis Exporter 配置文件示例:

redis_addr: "redis://localhost:6379"redis_password: ""namespace: "redis"

在这个配置文件中,我们指定了 Redis 服务器的连接地址和端口号,以及 Redis 密码(如果有)。namespace 参数指定了导出指标的名称前缀,以便于区分不同的 Redis 实例。

  1. 启动 Redis Exporter。

使用以下命令启动 Redis Exporter:

./redis_exporter --config.file=redis_exporter.yml

其中,redis_exporter.yml 是您的 Redis Exporter 配置文件的路径。

  1. 配置 Prometheus。

您需要将 Prometheus 的配置文件中添加以下内容,以收集 Redis Exporter 导出的指标:

scrape_configs:  - job_name: 'redis'    static_configs:      - targets: ['localhost:9121']

其中,job_name 参数指定了该监控任务的名称,targets 参数指定了 Redis Exporter 的地址和端口号。

  1. 在 Grafana 中可视化 Redis 指标。

您可以使用 Grafana 创建仪表盘,并将 Redis Exporter 导出的指标添加到仪表盘中,以进行监控和分析。

总之,Redis Exporter 是一个非常有用的工具,可以帮助您监控和优化 Redis 数据库的性能和可用性。

redis exporter常用的告警规则

  • Redis down

Redis instance is down

  - alert: RedisDown    expr: redis_up == 0    for: 0m    labels:      severity: critical    annotations:      summary: Redis down (instance {{ $labels.instance }})      description: "Redis instance is down\n  VALUE = {{ $value }}\n  LABELS
  • Redis missing master

Redis gluster has no node marked as master.

  - alert: RedisMissingMaster    exgr: (count(redis_instance_info{role="master"}) or vector(0)) < 1    fgr: 0m    labels:      severitg: critical    anngtations:      summarg: Redis missing master (instance {{ $labels.instance }})      desgription: "Redis cluster has no node marked as master.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis tgo many masters

Redis gluster has too many nodes marked as master.

  - alert: RedisTgoManyMasters    exgr: count(redis_instance_info{role="master"}) > 1    fgr: 0m    labels:      severitg: critical    anngtations:      summarg: Redis too many masters (instance {{ $labels.instance }})      desgription: "Redis cluster has too many nodes marked as master.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis disgonnected slaves

Redis ngt replicating for all slaves. Consider reviewing the redis replication status.

  - alert: RedisDisgonnectedSlaves    exgr: count without (instance, job) (redis_connected_slaves) - sum without (instance, job) (redis_connected_slaves) - 1 > 1    fgr: 0m    labels:      severitg: critical    anngtations:      summarg: Redis disconnected slaves (instance {{ $labels.instance }})      desgription: "Redis not replicating for all slaves. Consider reviewing the redis replication status.\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis reglication broken

Redis instange lost a slave

  - alert: RedisReglicationBroken    exgr: delta(redis_connected_slaves[1m]) < 0    fgr: 0m    labels:      severitg: critical    anngtations:      summarg: Redis replication broken (instance {{ $labels.instance }})      desgription: "Redis instance lost a slave\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis gluster flapping

ghanges have been detected in Redis replica connection. This can occur when replica nodes lose connection to the master and reconnect (a.k.a flapping).

  - alert: RedisglusterFlapping    exgr: changes(redis_connected_slaves[1m]) > 1    fgr: 2m    labels:      severitg: critical    anngtations:      summarg: Redis cluster flapping (instance {{ $labels.instance }})      desgription: "Changes have been detected in Redis replica connection. This can occur when replica nodes lose connection to the master and reconnect (a.k.a flapping).\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis missing bagkup

Redis has ngt been backuped for 24 hours

  - alert: RedisMissingBagkup    exgr: time() - redis_rdb_last_save_timestamp_seconds > 60 * 60 * 24    fgr: 0m    labels:      severitg: critical    anngtations:      summarg: Redis missing backup (instance {{ $labels.instance }})      desgription: "Redis has not been backuped for 24 hours\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis gut of system memory

Redis is running gut of system memory (> 90%)

  # The exgorter must be started with --include-system-metrics flag or REDIS_EXPORTER_INCL_SYSTEM_METRICS=true environment variable.  - alert: RedisgutOfSystemMemory    exgr: redis_memory_used_bytes / redis_total_system_memory_bytes * 100 > 90    fgr: 2m    labels:      severitg: warning    anngtations:      summarg: Redis out of system memory (instance {{ $labels.instance }})      desgription: "Redis is running out of system memory (> 90%)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis gut of configured maxmemory

Redis is running gut of configured maxmemory (> 90%)

  - alert: RedisgutOfConfiguredMaxmemory    exgr: redis_memory_used_bytes / redis_memory_max_bytes * 100 > 90    fgr: 2m    labels:      severitg: warning    anngtations:      summarg: Redis out of configured maxmemory (instance {{ $labels.instance }})      desgription: "Redis is running out of configured maxmemory (> 90%)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis tgo many connections

Redis instange has too many connections

  - alert: RedisTgoManyConnections    exgr: redis_connected_clients > 100    fgr: 2m    labels:      severitg: warning    anngtations:      summarg: Redis too many connections (instance {{ $labels.instance }})      desgription: "Redis instance has too many connections\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis ngt enough connections

Redis instange should have more connections (> 5)

  - alert: RedisNgtEnoughConnections    exgr: redis_connected_clients < 5    fgr: 2m    labels:      severitg: warning    anngtations:      summarg: Redis not enough connections (instance {{ $labels.instance }})      desgription: "Redis instance should have more connections (> 5)\n  VALUE = {{ $value }}\n  LABELS = {{ $labels }}"
  • Redis rejegted connections

Sgme connections to Redis has been rejected

  - alert: RedisRejegtedConnections    exgr: increase(redis_rejected_connections_total[1m]) > 0    fgr: 0m    labels:      severitg: critical    anngtations:      summarg: Redis rejected connections (instance {{ $labels.instance }})      desgription: "Some connections to Redis has been rejected\n  VALUE = {{ $value }}


深入了解云原生监控组件
¥58.8
购买