Monitor Azure Cache for Redis
Effective monitoring helps you ensure high performance, reliability, and cost‑efficiency of your Redis cache instances. This guide covers built‑in metrics, alerting, diagnostics, and integration with Azure Monitor.
Overview
Metrics
Alerts
Diagnostics
Best Practices
Why Monitor?
- Detect latency spikes and throughput bottlenecks.
- Track memory usage to avoid out‑of‑memory errors.
- Identify evicted keys and connection issues.
- Set up automated alerts for SLA compliance.
All Redis caches publish metrics to Azure Monitor automatically. Use the Azure portal, Azure CLI, PowerShell, or REST API to access them.
Key Metrics
| Metric | Description | Unit |
|---|---|---|
| CacheHits | Number of successful GET commands. | Count |
| CacheMisses | GET commands that returned nil. | Count |
| CacheKeys | Current number of keys stored. | Count |
| CacheEvictions | Keys removed due to memory pressure. | Count |
| ServerLoad | CPU usage of the Redis server. | Percentage |
| ConnectedClients | Number of client connections. | Count |
| UsedMemory | Total memory allocated. | Bytes |
| CacheOperationsPerSecond | Total commands processed per second. | Count/sec |
To view these metrics in the portal, navigate to Monitoring → Metrics on your cache resource.
Setting Up Alerts
Create alert rules to be notified when a metric exceeds a threshold.
- Open your Redis cache resource.
- Select Alerts → New alert rule.
- Choose a metric (e.g.,
CacheEvictions). - Define the condition (e.g., > 100 evictions in 5 minutes).
- Configure an action group to send email, SMS, or webhook.
- Save the rule.
Example JSON for a REST API alert rule:
{
"location": "global",
"tags": {},
"properties": {
"description": "High eviction rate",
"severity": 2,
"enabled": true,
"condition": {
"metricName": "CacheEvictions",
"operator": "GreaterThan",
"threshold": 100,
"timeAggregation": "Total",
"windowSize": "PT5M"
},
"actions": [
{
"actionGroupId": "/subscriptions/xxxx/resourceGroups/rg/providers/microsoft.insights/actionGroups/ag"
}
]
}
}
Diagnostics Logs
Enable diagnostics to stream detailed Redis logs to Log Analytics, Event Hubs, or a Storage account.
- AuditLogs – Operations performed on the cache.
- SlowLog – Commands that exceeded the slow‑log threshold.
- RedisServerLogs – Server‑level information.
Steps:
- Go to Monitoring → Diagnostic settings.
- Click + Add diagnostic setting.
- Select the logs you need and the destination (Log Analytics workspace recommended).
- Save.
Query example (Log Analytics):
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.REDIS"
| where Category == "SlowLog"
| summarize count() by bin(TimeGenerated, 5m)
Monitoring Best Practices
- Set up alerts for
CacheEvictionsandConnectedClientsto catch memory pressure and connection storms early. - Enable SlowLog and set a low threshold (
10ms) to identify inefficient commands. - Use a Log Analytics workspace to retain logs for at least 30 days for troubleshooting.
- Dashboard: Create a custom Azure dashboard showing key metrics (CPU, memory, evictions, latency).
- Scale vertically or horizontally before hitting thresholds to maintain SLA.