Monitoring Redis Performance using OpenTelemetry
What is OpenTelemetry Collector?
OpenTelemetry Collector is a proxy service between your application and a distributed tracing tool. Collector receives telemetry data, transforms the data, and then exports it to tracing tools that can store the data permanently.
Collector can also work as an agent that pulls telemetry data from monitored programs and then exports it to the configured backends. In this article, we will use OpenTelemetry 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:
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.43.0/otelcol-contrib_0.43.0_linux_amd64.deb
sudo dpkg -i otelcol-contrib_0.43.0_linux_amd64.deb
wget https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.43.0/otelcol_0.43.0_linux_amd64.rpm
sudo rpm -ivh otelcol_0.43.0_linux_amd64.rpm
You can check the status of the installed service with:
sudo systemctl status otelcol-contrib
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.
See OpenTelemetry Collector configuration to learn more.
Redis receiver
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 otelcol-contrib
You can also check OpenTelemetry Collector logs for any errors:
sudo journalctl -u otelcol-contrib -f
Available metrics
When telemetry data reaches Uptrace, it automatically generates a Redis dashboard from the pre-defined template.
Prometheus
You can also send OpenTelemetry metrics to Prometheus using OpenTelemetry Prometheus exporter.