There are several Redis metrics that can be viewed through redis-cli.
Redis INFO command
Running the INFO command provides many of the metrics available in a single view.
There are several sections that can be pulled individually. For example, if you wanted to just get the CLIENTS section you can pass that section as an argument to the INFO command.
Sections
Server: the current Redis server info.
Metrics of note:
redis_versionprocess_idconfig_fileuptime_in_secondsuptime_in_days
Clients: available data on clients connected or failed connections.
Metrics of note:
connected_clientsblocked_clients
Memory: memory usage and stats
Metrics of note:
used_memorymem_fragmentation_ratio
Persistence: RDB or AOF metrics
Metrics of note:
rdb_last_save_timerdb_changes_since_last_saveaof_rewrite_in_progress
Stats: some general statistics
Metrics of note:
keyspace_hitskeyspace_missesexpired_keysevicted_keysinstantaneous_ops_per_sec
Replication: replication data including primary/replica identifiers and offsets
Metrics of note:
master_link_down_sinceconnected_slavesmaster_last_io_seconds_ago
CPU: compute consumption stats
Metrics of note:
used_cpu_sysused_cpu_user
Modules: data from any loaded modules
Metrics of note (per module):
veroptions
Cluster: whether cluster is enabled
Metric of note:
cluster_enabled
Keyspace: keys and expiration data
Metrics of note (per db):
keysexpiresavg_ttl
The output can be read from the results or piped into a file.
This could be done at intervals and consumed by a local or third party monitoring service.
Some of the data returned by INFO are going to be static. For example the Redis version which won't change until an update is made. Other data is dynamic, for keyspace_hits ÷ keyspace_misses. The latter could be taken to compute a hit ratio and observed as a long term metric. The replication section field master_link_down_since could be a metric to connect an alert.
Some examples of possible alerts that could be setup for a given metric:
| Metric | Example Alert |
|---|---|
uptime_in_seconds | < 300 seconds: to ensure the server is staying up |
connected_clients | < minimum number of expected application connections |
master_link_down_since | > 30 seconds: replication should be operational |
rdb_last_save_time | > maximum acceptable interval without taking a snapshot |
NOTE
This is not an exhaustive list, but just to give you an idea of how the metrics in INFO could be used.
Latency and stats data via redis-cli options
The redis-cli client has some built-in options that allow you to pull some real-time latency and stats data.
NOTE
These are not available as commands from Redis but as options in redis-cli.
Latency options:
Continuously sample latency:
The raw or csv output flag can be added:
In order to sample for longer than one second you can use latency-history which has a default interval of 15 seconds but can be specified using the -i param.
This can also be combined with the csv or raw output format flag.
Both of these could be piped to a file as well.
The latency-dist option shows latency as a spectrum. The default interval is one second but can be changed using the -i param.

Stats option:
Get rolling stats from the server using the stat flag.
Memory stats
Redis includes a MEMORY command that includes a subcommand to get stats.
These values are available in the INFO MEMORY command as well, but here they are returned in a typical Redis RESP Array reply.
There is also a LATENCY DOCTOR subcommand with an analysis report of the current memory metrics.
Latency Monitoring
As we know Redis is fast and as a result is often used in very extreme scenarios where low latency is a must. Redis has a feature called Latency Monitoring which allows you to dig into possible latency issues. Latency monitoring is composed of the following conceptual parts:
- Latency hooks that sample different latency sensitive code paths.
- Time series recording of latency spikes split by different events.
- A reporting engine to fetch raw data from the time series.
- Analysis engine to provide human readable reports and hints according to the measurements.
By default this feature is disabled because most of the time it is not needed. In order to enable it you can update the threshold time in milliseconds that you want to monitor in your Redis configuration. Events that take longer than the threshold will be logged as latency spikes. The threshold configuration should be set accordingly if the requirement is to identify all events blocking the server for a time of 10 milliseconds or more.
If the debugging session is intended to be temporary the threshold can be set via redis-cli.
To disable the latency framework the threshold should be set back to 0.
The latency data can be viewed using the LATENCY command with it's subcommands:
LATENCY LATEST- latest samples for all eventsLATENCY HISTORY- latest time series for a given eventLATENCY RESET- resets the time series dataLATENCY GRAPH- renders an ASCII-art graphLATENCY DOCTOR- analysis report
In order to make use of these commands you need to make yourself familiar with the different events that the latency monitoring framework is tracking. (taken from https://redis.io/topics/latency-monitor" )
| Metric | Example Alert |
|---|---|
command | regular commands |
fast-command | O(1) and O(log N) commands |
fork | the fork(2) system call |
comrdb-unlink-temp-file | the unlink(2) system call |
aof-write | writing to the AOF - a catchall event fsync(2) system calls |
aof-fsync-always | the fsync(2) system call when invoked by the appendfsync allways policy |
aof-write-pending-fsync | the fsync(2) system call when there are pending writes |
aof-write-active-child | the fsync(2) system call when performed by a child process |
aof-write-alone | the fsync(2) system call when performed by the main process |
aof-fstat | the fstat(2) system call |
aof-rename | the rename(2) system call for renaming the temporary file after completing BGREWRITEAOF |
aof-rewrite-diff-write | writing the differences accumulated while performing BGREWRITEAOF |
active-defrag-cycle | the active defragmentation cycle |
expire-cycle | the expiration cycle |
eviction-cycle | the eviction cycle |
eviction-del | deletes during the eviction cycle |
For example, you can use the LATENCY LATEST subcommand and you may see some data like this:
The results of this command provide the timestamp, latency and max latency for this event. Utilizing the events table above I can see we had latency spikes for a regular command with the latest and max latency of 600 MS while a O(1) or O(log N) command had a latency spike of 12 MS.
Some of the latency commands require a specific event be passed.
While the cost of enabling latency monitoring is near zero and memory requirements are very small it will raise your baseline memory usage so if you are getting the required performance out of Redis there is no need to leave this enabled.
Monitoring Tools
There are many open source monitoring tools and services to visualize your Redis metrics - some of which also provide alerting capabilities.
One example of this is the Redis Data Source for Grafana. It is a Grafana plug-in that allows users to connect to the Redis database and build dashboards to easily observe Redis data. It provides an out-of-the-box predefined dashboard but also lets you build customized dashboards tuned to your specific needs.