redis-observability
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRedis Observability
Redis可观测性
What to watch, what to run, and what to alert on. Covers the metrics every Redis deployment should monitor and the built-in commands for ad-hoc diagnosis.
需要关注的内容、执行的命令以及告警规则。涵盖所有Redis部署都应监控的指标,以及用于临时诊断的内置命令。
When to apply
适用场景
- Setting up monitoring or alerts for a Redis instance.
- Diagnosing a Redis performance regression (high latency, memory pressure, connection storms).
- Profiling a slow or pipeline.
FT.SEARCH - Wiring Redis metrics into Prometheus, Datadog, CloudWatch, or similar.
- 为Redis实例设置监控或告警。
- 诊断Redis性能退化问题(高延迟、内存压力、连接风暴)。
- 分析慢查询或管道操作。
FT.SEARCH - 将Redis指标接入Prometheus、Datadog、CloudWatch等监控系统。
1. Monitor these metrics
1. 监控这些指标
These come from and should be exported to your monitoring system.
INFO| Metric | What it tells you | Alert when |
|---|---|---|
| Current memory usage | > 80% of |
| Open connections | Sudden spikes or drops |
| Clients waiting on blocking ops | > 0 sustained |
| Current throughput | Significant drops |
| Cache hit ratio | Hit ratio < 80% |
| Hit | > 0 |
| Last persistence snapshot | Too old vs. RPO |
python
info = redis.info()
hit_ratio = info["keyspace_hits"] / max(1, info["keyspace_hits"] + info["keyspace_misses"])
print(f"Memory: {info['used_memory_human']}")
print(f"Clients: {info['connected_clients']}")
print(f"Ops/sec: {info['instantaneous_ops_per_sec']}")
print(f"Hit ratio: {hit_ratio:.1%}")See references/metrics.md.
这些指标来自命令,应导出到你的监控系统中。
INFO| 指标 | 说明 | 告警条件 |
|---|---|---|
| 当前内存使用量 | 超过 |
| 活跃连接数 | 出现突然的激增或骤降 |
| 等待阻塞操作的客户端数 | 持续大于0 |
| 当前吞吐量 | 出现显著下降 |
| 缓存命中率 | 命中率低于80% |
| 达到 | 大于0 |
| 最后一次持久化快照时间 | 与恢复点目标(RPO)相比过于陈旧 |
python
info = redis.info()
hit_ratio = info["keyspace_hits"] / max(1, info["keyspace_hits"] + info["keyspace_misses"])
print(f"Memory: {info['used_memory_human']}")
print(f"Clients: {info['connected_clients']}")
print(f"Ops/sec: {info['instantaneous_ops_per_sec']}")
print(f"Hit ratio: {hit_ratio:.1%}")查看references/metrics.md。
2. Built-in commands for debugging
2. 用于调试的内置命令
Reach for these when something looks off.
| Topic | Command |
|---|---|
| Slow commands | |
| Server snapshot | |
| Memory diagnostics | |
| Connections | |
| RQE / Search | |
The two most useful for incident triage:
- to find queries that exceeded the
SLOWLOG GETthreshold (10ms by default). The output shows the exact command and duration in microseconds.slowlog-log-slower-than - for memory pressure — it returns a one-paragraph summary of what's unusual about memory usage right now.
MEMORY DOCTOR
python
for entry in redis.slowlog_get(10):
print(f"{entry['duration']}μs {entry['command']}")See references/commands.md.
当出现异常时,可以使用这些命令。
| 主题 | 命令 |
|---|---|
| 慢命令 | |
| 服务器快照 | |
| 内存诊断 | |
| 连接管理 | |
| RQE/搜索 | |
事件排查中最有用的两个命令:
- :用于查找超过
SLOWLOG GET阈值(默认10毫秒)的查询。输出会显示具体命令和执行时长(微秒)。slowlog-log-slower-than - :用于排查内存压力问题——它会返回一段关于当前内存使用异常情况的总结。
MEMORY DOCTOR
python
for entry in redis.slowlog_get(10):
print(f"{entry['duration']}μs {entry['command']}")查看references/commands.md。
3. Redis Insight
3. Redis Insight
For interactive use (running queries, browsing keys, profiling indexes), Redis Insight is the official GUI. It surfaces the same / / data visually and includes Redis Copilot for natural-language queries. Useful during development and incident response; not a replacement for exporting metrics to your monitoring system.
SLOWLOGINFOFT.PROFILE对于交互式操作(执行查询、浏览键、分析索引),Redis Insight是官方GUI工具。它以可视化方式展示//的数据,还包含支持自然语言查询的Redis Copilot。适用于开发和事件响应阶段,但不能替代将指标导出到监控系统的操作。
SLOWLOGINFOFT.PROFILE