Monitoring Redis Metrics with ClickStack

[Edit this page](https://github.com/ClickHouse/clickhouse-docs/blob/main/docs/use-cases/observability/clickstack/ingesting-data/integration-examples/redis-metrics.md)

TL;DR

Monitor Redis performance metrics in ClickStack using the OTel Redis receiver. Includes a demo dataset and pre-built dashboard.

## Integration with existing Redis[​](#existing-redis "Direct link to Integration with existing Redis")

This section covers configuring your existing Redis installation to send metrics to ClickStack by configuring the ClickStack OTel collector with the Redis receiver.

If you would like to test the Redis Metrics integration before configuring your own existing setup, you can test with our preconfigured demo dataset in the [following section](#demo-dataset).

##### Prerequisites[​](#prerequisites "Direct link to Prerequisites")

- ClickStack instance running
- Existing Redis installation (version 3.0 or newer)
- Network access from ClickStack to Redis (default port 6379)
- Redis password if authentication is enabled

Verify Redis connection

#### Verify Redis connection[​](#verify-redis "Direct link to Verify Redis connection")

First, verify you can connect to Redis and that the INFO command works:

```
# Test connection
redis-cli ping
# Expected output: PONG

# Test INFO command (used by metrics collector)
redis-cli INFO server
# Should display Redis server information
```

If Redis requires authentication:

```
redis-cli -a <your-password> ping
```

**Common Redis endpoints:**

- **Local installation**: `localhost:6379`
- **Docker**: Use container name or service name (e.g., `redis:6379`)
- **Remote**: `<redis-host>:6379`

Create custom OTel collector configuration

#### Create custom OTel collector configuration[​](#custom-otel "Direct link to Create custom OTel collector configuration")

ClickStack allows you to extend the base OpenTelemetry collector configuration by mounting a custom configuration file and setting an environment variable. The custom configuration is merged with the base configuration managed by HyperDX via OpAMP.

Create a file named `redis-metrics.yaml` with the following configuration:

```
receivers:
  redis:
    endpoint: "localhost:6379"
    collection_interval: 10s
    # Uncomment if Redis requires authentication
    # password: ${env:REDIS_PASSWORD}
    
    # Configure which metrics to collect
    metrics:
      redis.commands.processed:
        enabled: true
      redis.clients.connected:
        enabled: true
      redis.memory.used:
        enabled: true
      redis.keyspace.hits:
        enabled: true
      redis.keyspace.misses:
        enabled: true
      redis.keys.evicted:
        enabled: true
      redis.keys.expired:
        enabled: true

processors:
  resource:
    attributes:
      - key: service.name
        value: "redis"
        action: upsert

service:
  pipelines:
    metrics/redis:
      receivers: [redis]
      processors:
        - resource
        - memory_limiter
        - batch
      exporters:
        - clickhouse
```

This configuration:

- Connects to Redis on `localhost:6379` (adjust endpoint for your setup)
- Collects metrics every 10 seconds
- Collects key performance metrics (commands, clients, memory, keyspace stats)
- **Sets the required `service.name` resource attribute** per [OpenTelemetry semantic conventions](https://opentelemetry.io/docs/specs/semconv/resource/#service)
- Routes metrics to the ClickHouse exporter via a dedicated pipeline

**Key metrics collected:**

- `redis.commands.processed` - Commands processed per second
- `redis.clients.connected` - Number of connected clients
- `redis.clients.blocked` - Clients blocked on blocking calls
- `redis.memory.used` - Memory used by Redis in bytes
- `redis.memory.peak` - Peak memory usage
- `redis.keyspace.hits` - Successful key lookups
- `redis.keyspace.misses` - Failed key lookups (for cache hit rate calculation)
- `redis.keys.expired` - Keys expired
- `redis.keys.evicted` - Keys evicted due to memory pressure
- `redis.connections.received` - Total connections received
- `redis.connections.rejected` - Rejected connections

Note

- You only define new receivers, processors, and pipelines in the custom config
- The `memory_limiter` and `batch` processors and `clickhouse` exporter are already defined in the base ClickStack configuration - you just reference them by name
- The `resource` processor sets the required `service.name` attribute per OpenTelemetry semantic conventions
- For production with authentication, store the password in an environment variable: `${env:REDIS_PASSWORD}`
- Adjust `collection_interval` based on your needs (10s default; lower values increase data volume)
- For multiple Redis instances, customize `service.name` to distinguish them (e.g., `"redis-cache"`, `"redis-sessions"`)

Configure ClickStack to load custom configuration

#### Configure ClickStack to load custom configuration[​](#load-custom "Direct link to Configure ClickStack to load custom configuration")

To enable custom collector configuration in your existing ClickStack deployment, you must:

1. Mount the custom config file at `/etc/otelcol-contrib/custom.config.yaml`
2. Set the environment variable `CUSTOM_OTELCOL_CONFIG_FILE=/etc/otelcol-contrib/custom.config.yaml`
3. Ensure network connectivity between ClickStack and Redis

##### Option 1: Docker Compose[​](#docker-compose "Direct link to Option 1: Docker Compose")

Update your ClickStack deployment configuration:

```
services:
  clickstack:
    # ... existing configuration ...
    environment:
      - CUSTOM_OTELCOL_CONFIG_FILE=/etc/otelcol-contrib/custom.config.yaml
      # Optional: If Redis requires authentication
      # - REDIS_PASSWORD=your-redis-password
      # ... other environment variables ...
    volumes:
      - ./redis-metrics.yaml:/etc/otelcol-contrib/custom.config.yaml:ro
      # ... other volumes ...
    # If Redis is in the same compose file:
    depends_on:
      - redis

  redis:
    image: redis:7-alpine
    ports:
      - "6379:6379"
    # Optional: Enable authentication
    # command: redis-server --requirepass your-redis-password
```

##### Option 2: Docker run (all-in-one image)[​](#all-in-one "Direct link to Option 2: Docker run (all-in-one image)")

If using the all-in-one image with `docker run`:

```
docker run --name clickstack \
  -p 8080:8080 -p 4317:4317 -p 4318:4318 \
  -e CUSTOM_OTELCOL_CONFIG_FILE=/etc/otelcol-contrib/custom.config.yaml \
  -v "$(pwd)/redis-metrics.yaml:/etc/otelcol-contrib/custom.config.yaml:ro" \
  clickhouse/clickstack-all-in-one:latest
```

**Important:** If Redis is running in another container, use Docker networking:

```
# Create a network
docker network create monitoring

# Run Redis on the network
docker run -d --name redis --network monitoring redis:7-alpine

# Run ClickStack on the same network (update endpoint to "redis:6379" in config)
docker run --name clickstack \
  --network monitoring \
  -p 8080:8080 -p 4317:4317 -p 4318:4318 \
  -e CUSTOM_OTELCOL_CONFIG_FILE=/etc/otelcol-contrib/custom.config.yaml \
  -v "$(pwd)/redis-metrics.yaml:/etc/otelcol-contrib/custom.config.yaml:ro" \
  clickhouse/clickstack-all-in-one:latest
```

Verify metrics in HyperDX

#### Verify metrics in HyperDX[​](#verifying-metrics "Direct link to Verify metrics in HyperDX")

Once configured, log into HyperDX and verify metrics are flowing:

1. Navigate to the Metrics explorer
2. Search for metrics starting with `redis.` (e.g., `redis.commands.processed`, `redis.memory.used`)
3. You should see metric data points appearing at your configured collection interval

## Demo dataset[​](#demo-dataset "Direct link to Demo dataset")

For users who want to test the Redis Metrics integration before configuring their production systems, we provide a pre-generated dataset with realistic Redis Metrics patterns.

Download the sample metrics dataset

#### Download the sample metrics dataset[​](#download-sample "Direct link to Download the sample metrics dataset")

Download the pre-generated metrics files (24 hours of Redis Metrics with realistic patterns):