You can collect metrics about your Redis instance with the OpenTelemetry collector. The collector is a component of OpenTelemetry that collects, processes, and exports telemetry data to New Relic (or any observability backend). The Redis receiver is designed to retrieve Redis INFO data from a single Redis instance, build metrics from that data, and send them to the next consumer at a configurable interval.
After going through the installation steps, you'll view this metric data in pre-built dashboards, create alert policies, and create custom queries and charts.
Prerequisites
In order to start collecting Redis metrics, you need to sign up for a free New Relic account.
Once you've signed up, make sure you've set up:
- The redis receiver component, as the collector requires access to Redis through an endpoint. Minimum version recommended is v0.83.0.
- The OpenTelemetry collector following OpenTelemetry docs
Install the OpenTelemetry collector
Install an OpenTelemetry distribution
You will need to install OpenTelemetry Collector Contrib Distro. If you're using another distribution, confirm that your chosen distribution has the following components:
Important
If your distribution does not have these components, then the config file in the next step does not apply.
Configure the OpenTelemetry collector
Update or create a new file called config.yaml
. Insert the following snippet into your new file:
receivers: redis: endpoint: "<YOUR_REDIS_HOSTNAME>:<REDIS_PORT>" metrics: # Enable redis.maxmemory optional metric redis.maxmemory: enabled: true
processors: # This is needed since redis receiver is not currently adding any means to understand to which redis server the metrics are referring to attributes/redis_metrics: include: match_type: regexp metric_names: # Notice that if with single or without quotes just one backslash is needed 'redis\..*' - "redis\\..*" actions: - action: upsert key: server.address value: "<YOUR_REDIS_HOSTNAME>" - action: upsert key: server.port value: "<REDIS_PORT>" # resource and resource-detection processors allow decorating the metrics with host attributes resource: attributes: - key: host.id from_attribute: host.name action: insert resourcedetection: detectors: ["env", "system"] resourcedetection/cloud: detectors: ["gcp", "ec2", "azure"] timeout: 2s override: false
exporters: otlp: endpoint: https://otlp.nr-data.net:443 headers: api-key: <NEW_RELIC_LICENSE_KEY>
service: telemetry: logs: pipelines: metrics: receivers: [redis] processors: - resourcedetection - resourcedetection/cloud - resource - attributes/redis_metrics exporters: [otlp]
- Replace the
NEW_RELIC_LICENSE_KEY
in the file with your own values. For more info, see the New Relic License key. - Since no identificator is attached by the OTel receiver to redis metrics, an attribute processor is needed to decorate metrics with
server.address
andserver.port
metadata. The attributesserver.address
andserver.port
are needed to be able to query and facet data differentiating between Redis servers and to create New Relic entities. - Moreover, separate pipelines with different instances of
resource/redis_metrics
are needed in case multiple Redis servers are monitored from a single otel collector to decorate each instance with the corresponding metadata.
To look at other configuration options, see:
Run the collector
Run the OpenTelemetry collector (the way to run it may vary depending on the chosen installation method). Example:
/usr/bin/otelcol-contrib --config ./config.yaml
Explore your data
Telemetry data originating from the OpenTelemetry Redis receiver, if properly decorated, generates redis entities. Entities are anything that reports data to New Relic and is identified by an unique entity ID.
Your monitored entities are the drivers of features like Entity Explorer, Workloads, and Lookout. Check this document for more information on how to get benefited from these experiences.
Query your data with metrics explorer
You may use the metrics explorer to check the metrics being ingested. All metrics reported by the redis receiver start by the "redis."
prefix.
The following NRQL queries show examples to help you query the metrics you received:
Listing number of metric updates ingested by metric name:
SELECT count(*) FROM Metric WHERE metricName LIKE 'redis.%' and instrumentation.provider='opentelemetry' facet metricName LIMIT maxQuerying a specific metric faceted by host:
SELECT average(redis.commands.processed) FROM Metric WHERE instrumentation.provider='opentelemetry' FACET host.name TIMESERIESListing dimensions available for a given metric:
SELECT keyset() FROM Metric WHERE metricName = 'redis.commands.processed'
For a list of all the supported metrics, please refer to the redis receiver metrics reference.
What's next?
With your Redis data reporting to New Relic, you can install the Redis Open Telemetry dashboard. This gives you a pre-made dashboard experience so you can track and monitor your Redis infrastructure.
If you're looking for help with other collector use cases, see the newrelic-opentelemetry-examples repository.