Redisの可視化と監視についてのガイド — 監視すべきメトリクス(メモリ使用量、接続数、キャッシュヒット率、1秒あたりの操作数、拒否された接続数)、トラブル発生時の調査に役立つ組み込みコマンド(SLOWLOG、INFO、MEMORY DOCTOR、CLIENT LIST、FT.PROFILE)、そしてRedis Insight GUI(グラフィカルな管理画面)をいつ使うべきかについて説明します。 **次のような場合に使用:** Redisインスタンスの監視とアラート設定を初めるとき、パフォーマンス低下の診断、FT.SEARCH クエリの遅延分析、またはPrometheusやDatadog などの監視ツールにRedisのメトリクスを連携させるとき。
Redis observability guidance — which metrics to monitor (memory, connections, hit ratio, ops/sec, rejected connections), which built-in commands to reach for during incident triage (SLOWLOG, INFO, MEMORY DOCTOR, CLIENT LIST, FT.PROFILE), and when to use the Redis Insight GUI. Use when setting up monitoring or alerts for a Redis instance, diagnosing a performance regression, profiling a slow FT.SEARCH query, or wiring Redis metrics into Prometheus, Datadog, or similar.
何を見守るか、何を実行するか、何についてアラートを設定するか。すべての Redis 配置(導入環境)が監視すべきメトリクス(数値指標)と、その場での診断に使う組み込みコマンドをまとめています。
FT.SEARCH クエリやパイプライン処理のボトルネック分析をするときこれらは INFO コマンドから得られ、監視システムにエクスポート(転送)すべき値です。
| メトリクス | 意味 | アラート条件 |
|---|---|---|
used_memory |
現在のメモリ使用量 | maxmemory の 80% 超過 |
connected_clients |
開いている接続数 | 急激な増減 |
blocked_clients |
ブロッキング操作を待つクライアント数 | 0より大きい状態が継続 |
instantaneous_ops_per_sec |
現在のスループット(処理速度) | 大幅な低下 |
keyspace_hits / keyspace_misses |
キャッシュ命中率 | 命中率 < 80% |
rejected_connections |
最大クライアント数に達した回数 | > 0 |
rdb_last_save_time |
最後にデータを保存した時刻 | 目標 RPO(許容停止時間)と比べて古すぎる |
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 を参照。
何か異常を感じたときに実行するコマンドです。
| 用途 | コマンド |
|---|---|
| 遅いコマンド | SLOWLOG GET 10 / SLOWLOG LEN / SLOWLOG RESET |
| サーバー状態のスナップショット | INFO all(または INFO memory / INFO stats / INFO clients / INFO replication) |
| メモリ診断 | MEMORY DOCTOR / MEMORY STATS / MEMORY USAGE <key> |
| 接続情報 | CLIENT LIST / CLIENT INFO |
| 検索機能 | FT.INFO <idx> / FT.PROFILE <idx> SEARCH QUERY "..." |
インシデント対応で最も役立つ 2 つ:
SLOWLOG GET — slowlog-log-slower-than 設定値(デフォルト 10ms)を超えたクエリを見つけます。実行時間がマイクロ秒単位で表示されます。MEMORY DOCTOR — メモリ逼迫の診断に使います。現在のメモリ使用状況で何が異常かを 1 段落の要約で返します。for entry in redis.slowlog_get(10):
print(f"{entry['duration']}μs {entry['command']}")
詳しくは references/commands.md を参照。
対話的な使用(クエリ実行、キー閲覧、インデックスのプロファイリング)には、公式 GUI ツールの Redis Insight が便利です。SLOWLOG / INFO / FT.PROFILE のデータを視覚的に表示でき、自然言語でクエリできる Redis Copilot も備えています。開発やインシデント対応時に活躍しますが、監視システムへのメトリクス転送の代替にはなりません。
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.
FT.SEARCH or pipeline.These come from INFO and should be exported to your monitoring system.
| Metric | What it tells you | Alert when |
|---|---|---|
used_memory |
Current memory usage | > 80% of maxmemory |
connected_clients |
Open connections | Sudden spikes or drops |
blocked_clients |
Clients waiting on blocking ops | > 0 sustained |
instantaneous_ops_per_sec |
Current throughput | Significant drops |
keyspace_hits / keyspace_misses |
Cache hit ratio | Hit ratio < 80% |
rejected_connections |
Hit maxclients cap |
> 0 |
rdb_last_save_time |
Last persistence snapshot | Too old vs. RPO |
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%}")
Reach for these when something looks off.
| Topic | Command |
|---|---|
| Slow commands | SLOWLOG GET 10 / SLOWLOG LEN / SLOWLOG RESET |
| Server snapshot | INFO all (or INFO memory / INFO stats / INFO clients / INFO replication) |
| Memory diagnostics | MEMORY DOCTOR / MEMORY STATS / MEMORY USAGE <key> |
| Connections | CLIENT LIST / CLIENT INFO |
| RQE / Search | FT.INFO <idx> / FT.PROFILE <idx> SEARCH QUERY "..." |
The two most useful for incident triage:
SLOWLOG GET to find queries that exceeded the slowlog-log-slower-than threshold (10ms by default). The output shows the exact command and duration in microseconds.MEMORY DOCTOR for memory pressure — it returns a one-paragraph summary of what's unusual about memory usage right now.for entry in redis.slowlog_get(10):
print(f"{entry['duration']}μs {entry['command']}")
For interactive use (running queries, browsing keys, profiling indexes), Redis Insight is the official GUI. It surfaces the same SLOWLOG / INFO / FT.PROFILE 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.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。