Monitor Azure Cache for Redis data using diagnostic settings
Article
Diagnostic settings in Azure are used to collect resource logs. An Azure resource emits resource logs and provides rich, frequent data about the operation of that resource. These logs are captured per request and are also referred to as "data plane logs". See diagnostic settings in Azure Monitor for a recommended overview of the functionality in Azure. The content of these logs varies by resource type. In Azure Cache for Redis, two options are available to log:
Connection Logs logs connections to the cache for security and diagnostic purposes.
Scope of availability
Tier
Basic, Standard, and Premium
Cache Metrics
Yes
Connection Logs
Yes
Cache Metrics
Azure Cache for Redis emits many metrics such as Server Load and Connections per Second that are useful to log. Selecting the AllMetrics option allows these and other cache metrics to be logged. You can configure how long the metrics are retained. See here for an example of exporting cache metrics to a storage account.
Connection Logs
Azure Cache for Redis uses Azure diagnostic settings to log information on client connections to your cache. Logging and analyzing this diagnostic setting helps you understand who is connecting to your caches and the timestamp of those connections. The log data could be used to identify the scope of a security breach and for security auditing purposes.
Prerequisites/Limitations of Connection Logging
Basic, Standard, and Premium tiers
Because connection logs in these tiers consist of point-in-time snapshots taken every 10 seconds, connections that are established and removed in-between 10-second intervals aren't logged.
Authentication events aren't logged.
All diagnostic settings may take up to 90 minutes to start flowing to your selected destination.
Enabling connection logs can cause a small performance degradation to the cache instance.
Only the Analytics Logs pricing plan is supported when streaming logs to Azure Log Analytics. For more information, see Azure Monitor pricing.
Note
It is always possible to use the INFO or CLIENT LIST commands to check who is connected to a cache instance on-demand.
Important
When selecting logs, you can chose either the specific Category or Category groups, which are predefined groupings of logs across Azure services. When you use Category groups, you can no longer configure the retention settings. If you need to determine retention duration for your connection logs, select the item in the Categories section instead.
Log Destinations
You can turn on diagnostic settings for Azure Cache for Redis instances and send resource logs to the following destinations:
Log Analytics workspace - doesn't need to be in the same region as the resource being monitored.
Event hub - diagnostic settings can't access event hub resources when virtual networks are enabled. Enable the Allow trusted Microsoft services to bypass this firewall? setting in event hubs to grant access to your event hub resources. The event hub must be in the same region as the cache.
You're charged normal data rates for storage account and event hub usage when you send diagnostic logs to either destination. You're billed under Azure Monitor not Azure Cache for Redis. When sending logs to Log Analytics, you're only charged for Log Analytics data ingestion.
Navigate to your Azure Cache for Redis account. Open the Diagnostic settings pane under the Monitoring section on the left. Then, select Add diagnostic setting.
In the Diagnostic settings pane, select ConnectedClientList from Categories.
Use the az monitor diagnostic-settings create command to create a diagnostic setting with the Azure CLI. For more for information on command and parameter descriptions, see Create diagnostic settings to send platform logs and metrics to different destinations. This example shows how to use the Azure CLI to stream data to four different endpoints:
These fields and properties appear in the ConnectedClientList log category. In Azure Monitor, logs are collected in the ACRConnectedClientList table under the resource provider name of MICROSOFT.CACHE.
Azure Storage field or property
Azure Monitor Logs property
Description
time
TimeGenerated
The timestamp of when the log was generated in UTC.
location
Location
The location (region) the Azure Cache for Redis instance was accessed in.
category
n/a
Available log categories: ConnectedClientList.
resourceId
_ResourceId
The Azure Cache for Redis resource for which logs are enabled.
operationName
OperationName
The Redis operation associated with the log record.
properties
n/a
The contents of this field are described in the rows that follow.
tenant
CacheName
The name of the Azure Cache for Redis instance.
roleInstance
RoleInstance
The role instance that logged the client list.
connectedClients.ip
ClientIp
The Redis client IP address.
connectedClients.privateLinkIpv6
PrivateLinkIpv6
The Redis client private link IPv6 address (if applicable).
connectedClients.count
ClientCount
The number of Redis client connections from the associated IP address.
Sample storage account log
If you send your logs to a storage account, the contents of the logs look like this.