Redis integration for Grafana Cloud
Redis is an in-memory data structure store frequently used as a key-value data store, cache, and message broker.
This integration includes 6 useful alerts and 1 pre-built dashboard to help monitor and visualize Redis metrics.
Before you begin
A user must be created in Redis for Grafana Alloy in order to connect to the cluster. We strongly recommend that you configure a separate user for the Agent, and give it only the strictly mandatory security privileges necessary for monitoring your node, as per the official documentation.
Install Redis integration for Grafana Cloud
- In your Grafana Cloud stack, click Connections in the left-hand menu.
- Find Redis and click its tile to open the integration.
- Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Redis metrics to your Grafana Cloud instance.
- Click Install to add this integration’s pre-built dashboard and alerts to your Grafana Cloud instance, and you can start monitoring your Redis setup.
Configuration snippets for Grafana Alloy
Simple mode
These snippets are configured to scrape a single Redis instance running locally with default ports.
First, manually copy and append the following snippets into your alloy configuration file.
Integrations snippets
prometheus.exporter.redis "integrations_redis_exporter" {
redis_addr = "localhost:6379"
}
discovery.relabel "integrations_redis_exporter" {
targets = prometheus.exporter.redis.integrations_redis_exporter.targets
rule {
target_label = "instance"
replacement = constants.hostname
}
rule {
target_label = "job"
replacement = "integrations/redis_exporter"
}
}
prometheus.scrape "integrations_redis_exporter" {
targets = discovery.relabel.integrations_redis_exporter.output
forward_to = [prometheus.remote_write.metrics_service.receiver]
job_name = "integrations/redis_exporter"
}
Advanced mode
The following snippets provide examples to guide you through the configuration process.
To instruct Grafana Alloy to scrape your Redis instances, manually copy and append the snippets to your alloy configuration file, then follow subsequent instructions.
Advanced integrations snippets
prometheus.exporter.redis "integrations_redis_exporter" {
redis_addr = "localhost:6379"
}
discovery.relabel "integrations_redis_exporter" {
targets = prometheus.exporter.redis.integrations_redis_exporter.targets
rule {
target_label = "instance"
replacement = constants.hostname
}
rule {
target_label = "job"
replacement = "integrations/redis_exporter"
}
}
prometheus.scrape "integrations_redis_exporter" {
targets = discovery.relabel.integrations_redis_exporter.output
forward_to = [prometheus.remote_write.metrics_service.receiver]
job_name = "integrations/redis_exporter"
}
This integrations uses the prometheus.exporter.redis component to generate metrics from a Redis instance.
Make sure to change the redis_addr
to the addresses of the Redis server you want to monitor in the agent config.
For the full array of configuration options, refer to the prometheus.exporter.redis component reference documentation.
This exporter must be linked with a discovery.relabel component to apply the necessary relabelings.
For each Redis instance to be monitored you must create a pair of these components.
Configure the following properties within each discovery.relabel
component:
instance
label:constants.hostname
sets theinstance
label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this Redis instance.
You can then scrape them by including each discovery.relabel
under targets
within the prometheus.scrape component.
Grafana Agent static configuration (deprecated)
The following section shows configuration for running Grafana Agent in static mode which is deprecated. You should use Grafana Alloy for all new deployments.
Before you begin
A user must be created in Redis for Grafana Agent in order to connect to the cluster. We strongly recommend that you configure a separate user for the Agent, and give it only the strictly mandatory security privileges necessary for monitoring your node, as per the official documentation.
Install Redis integration for Grafana Cloud
- In your Grafana Cloud stack, click Connections in the left-hand menu.
- Find Redis and click its tile to open the integration.
- Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Redis metrics to your Grafana Cloud instance.
- Click Install to add this integration’s pre-built dashboard and alerts to your Grafana Cloud instance, and you can start monitoring your Redis setup.
Post-install configuration for the Redis integration
This integration is configured to work with the redis_exporter
, which is embedded in Grafana Agent.
Enable the integration by manually adding the provided snippet to your agent configuration file.
Make sure to change the redis_addr
to the addresses of the Redis server you want to monitor in the agent config.
For a full description of configuration options see how to configure the redis_exporter_config
block in the agent documentation.
Configuration snippets for Grafana Agent
Below integrations
, insert the following lines and change the URLs according to your environment:
redis_exporter:
enabled: true
redis_addr: localhost:6379 # replace with your connection string
instance: '<your-instance-name>'
Full example configuration for Grafana Agent
Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the Redis integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.
integrations:
prometheus_remote_write:
- basic_auth:
password: <your_prom_pass>
username: <your_prom_user>
url: <your_prom_url>
agent:
enabled: true
relabel_configs:
- action: replace
source_labels:
- agent_hostname
target_label: instance
- action: replace
target_label: job
replacement: "integrations/agent-check"
metric_relabel_configs:
- action: keep
regex: (prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
source_labels:
- __name__
# Add here any snippet that belongs to the `integrations` section.
# For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
redis_exporter:
enabled: true
redis_addr: localhost:6379 # replace with your connection string
instance: '<your-instance-name>'
logs:
configs:
- clients:
- basic_auth:
password: <your_loki_pass>
username: <your_loki_user>
url: <your_loki_url>
name: integrations
positions:
filename: /tmp/positions.yaml
scrape_configs:
# Add here any snippet that belongs to the `logs.configs.scrape_configs` section.
# For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
metrics:
configs:
- name: integrations
remote_write:
- basic_auth:
password: <your_prom_pass>
username: <your_prom_user>
url: <your_prom_url>
scrape_configs:
# Add here any snippet that belongs to the `metrics.configs.scrape_configs` section.
# For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
global:
scrape_interval: 60s
wal_directory: /tmp/grafana-agent-wal
Dashboards
The Redis integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.
- Redis Dashboard for Prometheus Redis Exporter 1.x
Overview
Alerts
The Redis integration includes the following useful alerts:
Alert | Description |
---|---|
RedisDown | Critical: Redis down (instance {{ $labels.instance }}) |
RedisOutOfMemory | Warning: Redis out of memory (instance {{ $labels.instance }}) |
RedisTooManyConnections | Warning: Redis too many connections (instance {{ $labels.instance }}) |
RedisClusterSlotFail | Warning: Number of hash slots mapping to a node in FAIL state (instance {{ $labels.instance }}) |
RedisClusterSlotPfail | Warning: Number of hash slots mapping to a node in PFAIL state (instance {{ $labels.instance }}) |
RedisClusterStateNotOk | Critical: Redis cluster state is not ok (instance {{ $labels.instance }}) |
Metrics
The most important metrics provided by the Redis integration, which are used on the pre-built dashboard and Prometheus alerts, are as follows:
- redis_blocked_clients
- redis_cluster_slots_fail
- redis_cluster_slots_pfail
- redis_cluster_state
- redis_commands_duration_seconds_total
- redis_commands_total
- redis_connected_clients
- redis_connected_slaves
- redis_db_keys
- redis_db_keys_expiring
- redis_evicted_keys_total
- redis_keyspace_hits_total
- redis_keyspace_misses_total
- redis_master_last_io_seconds_ago
- redis_memory_fragmentation_ratio
- redis_memory_max_bytes
- redis_memory_used_bytes
- redis_memory_used_rss_bytes
- redis_total_system_memory_bytes
- redis_up
- up
Changelog
# 0.0.6 - November 2023
* Replaced Angular dashboard panels with React panels
# 0.0.5 - July 2023
* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.
# 0.0.4 - May 2023
* Update mixin to latest version:
- Add RedisClusterSlot alerts
# 0.0.3 - May 2022
* Update mixin to latest version:
- Fix selector
# 0.0.2 - October 2021
* Update mixin to latest version:
- Update queries to use $__rate_interval
# 0.0.1 - October 2020
* Initial release
Cost
By connecting your Redis instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.