# Redis

The OpenTelemetry Collector reads Redis metrics with its Redis receiver and tails the server log with the filelog receiver, then sends both to Epok over OTLP/HTTP. Run it on the database host or next to it. Tested with Redis 7.4 over TLS with this ACL user, and with a replica and collector 0.162.0.

## 1. Create a monitoring user

The receiver only runs INFO, so an ACL user with +info +ping is enough. The admin password comes from REDISCLI\_AUTH and the new one goes in on stdin; neither is on the command line. Use the same server name, TLS port and CA file as the collector config in step 3.

```
read -rsp 'Redis admin password: ' A; echo; read -rsp 'Monitoring password: ' P; echo
printf 'ACL SETUSER epok_monitor on >%s +info +ping\n' "$P" | REDISCLI_AUTH="$A" \
  redis-cli -h db.example.internal -p 6380 --tls --cacert /etc/otelcol-contrib/db-ca.pem
unset A P
```

## 2. Turn on the logs you want

The config reads the file set by logfile in redis.conf. Warnings (the # level) become level:warn.

```
logfile /var/log/redis/redis.log
```

The collector's user must be able to read the log files. On most installs that means adding it to the database's group. Change the `include:` paths if your logs live elsewhere.

Personal data: statement text can contain email addresses, names or tokens. The file replaces every literal in a logged statement with `?` on your host, before anything is sent. Values that the database writes into an error message itself are not rewritten, so leave statement logging off where that matters.

## 3. Run the collector

Install `otel/opentelemetry-collector-contrib:0.162.0` (or the matching otelcol-contrib package). Put `EPOK_INGEST_KEY` (an ingest-only key from Settings, then API Keys) and `REDIS_PASSWORD` in the collector's environment file, mode 0600, typed at a prompt that does not echo. Neither goes in the config file or on a command line.

```
read -rsp 'Epok ingest key: ' K; echo; read -rsp 'Monitoring password: ' P; echo
printf 'EPOK_INGEST_KEY=%s\nREDIS_PASSWORD=%s\n' "$K" "$P" | sudo tee -a /etc/otelcol-contrib/otelcol-contrib.conf >/dev/null
unset K P
sudo chmod 600 /etc/otelcol-contrib/otelcol-contrib.conf
```

The connection is TLS with the server certificate verified: set `endpoint` to the server name in its certificate and `ca_file` to the CA that signed it. Plain TCP is only for a collector on the database host; the file shows those localhost lines as a comment. The same file is in the app under Connect.

```
# otelcol-redis.yaml: Redis metrics + server log to Epok
# Collector: otel/opentelemetry-collector-contrib:0.162.0 (pinned; tested with Redis 7.4)
#
# Secrets never go in this file or on a command line. Put them in the collector's
# environment file (otelcol-contrib package: /etc/otelcol-contrib/otelcol-contrib.conf,
# or an EnvironmentFile= of your own, mode 0600):
#   read -rsp 'Epok ingest key: ' K; echo; read -rsp 'Monitoring password: ' P; echo
#   printf 'EPOK_INGEST_KEY=%s\nREDIS_PASSWORD=%s\n' "$K" "$P" | sudo tee -a /etc/otelcol-contrib/otelcol-contrib.conf >/dev/null
#   unset K P
#
# Monitoring user: the receiver only runs INFO, so an ACL user with +info +ping is enough
# (admin password from REDISCLI_AUTH, the new one on stdin, neither on argv):
#   read -rsp 'Monitoring password: ' P; echo
#   read -rsp 'Redis admin password: ' A; echo
#   printf 'ACL SETUSER epok_monitor on >%s +info +ping\n' "$P" | REDISCLI_AUTH="$A" \
#     redis-cli -h db.example.internal -p 6380 --tls --cacert /etc/otelcol-contrib/db-ca.pem
#   unset A P

receivers:
  redis:
    endpoint: db.example.internal:6380   # the server's TLS port, name as in its certificate
    username: epok_monitor
    password: ${env:REDIS_PASSWORD}
    collection_interval: 30s
    tls:
      insecure: false            # TLS on and the server certificate verified
      ca_file: /etc/otelcol-contrib/db-ca.pem   # the CA that signed the server certificate
      # LOCALHOST ONLY (collector on the Redis host, server without TLS):
      #   endpoint: localhost:6379
      #   tls: {insecure: true}
    metrics:
      redis.maxmemory: {enabled: true}
      redis.role: {enabled: true}
      redis.cmd.calls: {enabled: true}
      redis.cmd.usec: {enabled: true}
      redis.cmd.latency: {enabled: true}
    resource_attributes:          # tell instances apart when one host runs several
      server.address: {enabled: true}
      server.port: {enabled: true}

  # Server log (logfile in redis.conf).
  filelog/redis:
    include: [/var/log/redis/*.log]
    start_at: end
    operators:
      # 1:M 20 Nov 2026 10:00:00.123 * Ready to accept connections tcp
      - type: regex_parser
        regex: '^(?P<redis_pid>\d+):(?P<redis_role>[XCSM]) (?P<redis_time>\d{1,2} \w{3} \d{4} \d{2}:\d{2}:\d{2}\.\d{3}) (?P<redis_level>[.\-*#]) (?P<message>.*)$'
        on_error: send
        severity:
          parse_from: attributes.redis_level
          mapping:
            debug: "."
            info: ["-", "*"]
            warn: "#"
      - type: move
        if: 'attributes.message != nil'
        from: attributes.message
        to: body
      - type: add
        field: attributes.db_system
        value: redis

processors:
  batch:
    send_batch_max_size: 10000   # at or under Epok's 10,000 entries per batch
  resourcedetection:
    detectors: [env, system]
    system:
      hostname_sources: [os]
  resource/redis:
    attributes:
      - key: service.name
        value: redis
        action: upsert

  # Log lines can carry client addresses or key names: the safer default below
  # (quoted strings, e-mail addresses, 0x…, numbers of 3+ digits become ?).
  transform/redact_logs:
    error_mode: ignore
    log_statements:
      - context: log
        statements:
          - 'replace_pattern(body, "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}", "?")'
          - 'replace_pattern(body, "Failing row contains \\((?s:.*)\\)", "Failing row contains (?)")'
          - 'replace_pattern(body, "\\)=\\([^)]*\\)", ")=(?)")'
          - 'replace_pattern(body, "''(?:[^'']|'''')*''", "?")'
          - 'replace_pattern(body, "\"(?:[^\"\\\\]|\\\\.)*\"", "?")'
          - 'replace_pattern(body, "(?i)\\b0x[0-9a-f]+\\b", "?")'
          - 'replace_pattern(body, "\\b\\d{3,}(?:\\.\\d+)?\\b", "?")'

exporters:
  otlphttp/epok:
    metrics_endpoint: https://ingest.epok.cloud/v1/metrics
    logs_endpoint: https://ingest.epok.cloud/v1/logs
    compression: gzip
    encoding: json
    headers:
      x-api-key: ${env:EPOK_INGEST_KEY}

service:
  pipelines:
    metrics:
      receivers: [redis]
      processors: [resourcedetection, resource/redis, batch]
      exporters: [otlphttp/epok]
    logs:
      receivers: [filelog/redis]
      processors: [resourcedetection, resource/redis, transform/redact_logs, batch]
      exporters: [otlphttp/epok]
```

## 4. Check that data arrives

Metrics arrive within a minute (one point every 30 seconds). In Metrics, search for any of these names:

redis\_clients\_connected, redis\_commands\_processed, redis\_cmd\_latency, redis\_keyspace\_hits, redis\_keyspace\_misses, redis\_memory\_used, redis\_keys\_evicted, redis\_slaves\_connected

Logs are searchable in Explore with these queries:

- `service:redis -record_type:metric level:warn`: warnings such as memory overcommit or a failed save
- `service:redis -record_type:metric`: every server log line (-record\_type:metric leaves out the metric points, which are also stored with service:redis)

## Dashboard

When database boards are on for your workspace, Settings, then Setup, then Quickstarts installs the Redis board: connections, throughput, latency or slow queries, cache hit ratio, replication and errors. Without it, every metric and log above is searchable and can be charted on your own dashboards.

## Limits

- The receiver does not read SLOWLOG; slow commands show as per-command latency (p50, p99, p99.9).
- Replication lag in bytes is not reported from the primary; the board shows connected replicas.
- No query samples, normalized query statistics or explain plans. Epok reads server metrics and logs only.

[OpenTelemetry Collector](https://epok.cloud/docs/install/otel-collector) [All install guides](https://epok.cloud/docs)
