Published on

Monitoring Redis Server with OpenTelemetry Collector

This article explains how to install and configure OpenTelemetry Collector to monitor Redis Server or Redis Cluster.


What is OpenTelemetry Collector?

OpenTelemetry Collector is a proxy service between your application and a tracing backend. It receives telemetry data, transforms the data, and then exports it to backends that can store the data permanently.

Collector can also work as an agent that pulls telemetry data (for example, metrics) from monitored programs and then exports it to the configured backends. In this article we will use Collector as an agent to collect Redis Server metrics.

Installing OpenTelemetry Collector

OpenTelemetry Collector distributes pre-compiled binaries for Linux, MacOS, and Windows. You can install and configure it within minutes.

To install otel-contrib-collector binary with the associated systemd service on Debian/Ubuntu:

wget https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/download/v0.34.0/otel-contrib-collector_0.34.0_amd64.deb
sudo dpkg -i otel-contrib-collector_0.34.0_amd64.deb

On RPM:

wget https://github.com/open-telemetry/opentelemetry-collector-contrib/releases/download/v0.34.0/otel-contrib-collector-0.34.0-1.x86_64.rpm
sudo rpm -ivh otel-contrib-collector-0.34.0-1.x86_64.rpm

You can check the status of the installed service with:

sudo systemctl status otel-contrib-collector

Configuring OpenTelemetry Collector

By default, you can find the config file at /etc/otel-contrib-collector/config.yaml. It has the following sections:

  • receivers configures how data gets into the Collector.
  • processors specifies what happens with the received data.
  • exporters configures how you send processed data to one or more backends.
  • service pulls the configured receivers, processors, and exporters together into a processing pipeline. Don't repeat a common mistake by configuring a receiver or an exporter without adding it to a processing pipeline.

You can learn more about Collector configuration at the official documentation.

Monitoring Redis

To start monitoring Redis, you need to replace /etc/otel-contrib-collector/config.yaml with the following config using Uptrace DSN:

receivers:
  otlp:
    protocols:
      grpc:
      http:
  hostmetrics:
    collection_interval: 10s
    scrapers:
      cpu:
      disk:
      load:
      filesystem:
      memory:
      network:
      paging:
  redis:
    endpoint: localhost:6379
    collection_interval: 10s

exporters:
  otlp:
    endpoint: otlp.uptrace.dev:4317
    headers: { 'uptrace-dsn': '<FIXME>' }

processors:
  resourcedetection:
    detectors: [system]
  batch:
    timeout: 10s

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [otlp]
    metrics:
      receivers: [otlp, redis, hostmetrics]
      processors: [batch, resourcedetection]
      exporters: [otlp]

Don't forget to restart the service:

sudo systemctl restart otel-contrib-collector

Checking OpenTelemetry Collector logs can also be a good idea:

sudo journalctl -u otel-contrib-collector -f

Available metrics

When telemetry data reaches Uptrace, it automatically generates a Redis dashboard from the pre-defined template.

Redis metrics

What's next

Next, you can use Collector configurator to tweak your config and create custom instruments using OpenTelemetry Metrics API.