Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add redis example #608

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ The [Getting Started Guides](./getting-started-guides/README.md) demonstrate how
OpenTelemetry is a big ecosystem and everything doesn't fit into the goals of the [getting started guides](#getting-started-guides). These "other examples" demonstrate how other areas of OpenTelemetry fit in with New Relic.

* Collector
* [OpenTelemetry Collector with OTLP and New Relic](./other-examples/collector/nr-config)
* [OpenTelemetry Collector with Host Monitoring and New Relic](./other-examples/collector/host-monitoring)
* [OpenTelemetry Collector with Confluent Cloud and New Relic](./other-examples/collector/confluentcloud)
* [OpenTelemetry Collector with Singlestore and New Relic](./other-examples/collector/singlestore)
* [OpenTelemetry Collector with HCP Consul and New Relic](./other-examples/collector/hcp-consul)
* [Telemetry data processing](./other-examples/collector/nr-config)
* [Host monitoring](./other-examples/collector/host-monitoring)
* [Confluent cloud monitoring](./other-examples/collector/confluentcloud)
* [Singlestore monitoring](./other-examples/collector/singlestore)
* [HCP Consul monitoring](./other-examples/collector/hcp-consul)
* [Redis monitoring](./other-examples/collector/redis)
* Java
* [OpenTelemetry Agent New Relic Config](./other-examples/java/agent-nr-config)
* [Micrometer Shim with OTLP Export](./other-examples/java/micrometer-shim)
Expand Down
7 changes: 7 additions & 0 deletions other-examples/collector/redis/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# New Relic API key to authenticate the call.
# docs: https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key
NEW_RELIC_API_KEY=

# The default US endpoint is set here. You can change the endpoint and port based on your requirements if needed.
# docs: https://docs.newrelic.com/docs/more-integrations/open-source-telemetry-integrations/opentelemetry/best-practices/opentelemetry-otlp/#configure-endpoint-port-protocol
NEW_RELIC_OTLP_ENDPOINT=https://otlp.nr-data.net/
35 changes: 35 additions & 0 deletions other-examples/collector/redis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Monitoring Redis with OpenTelemetry Collector

This simple example demonstrates monitoring redis with the [OpenTelemetry collector](https://opentelemetry.io/docs/collector/), using the [redis receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/redisreceiver) and sending the data to New Relic via OTLP.

## Requirements

* [Docker compose](https://docs.docker.com/compose/) must be installed and the docker daemon must be running.
* [A New Relic account](https://one.newrelic.com/)
* [A New Relic license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#license-key)

## Running the application

1. Set the following environment variables to configure OpenTelemetry to send
data to New Relic:

```shell
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net
export OTEL_EXPORTER_OTLP_HEADERS=api-key=<your_license_key>
Comment on lines +17 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.nr-data.net
export OTEL_EXPORTER_OTLP_HEADERS=api-key=<your_license_key>
export NEW_RELIC_OTLP_ENDPOINT=https://otlp.nr-data.net
export NEW_RELIC_API_KEY=<your_license_key>

```

* If your account is based in the EU, set the endpoint to: [https://otlp.eu01.nr-data.net](https://otlp.eu01.nr-data.net)

2. Run the application with the following command.

```shell
docker compose up
```

## Viewing your data

To review your redis data in New Relic, navigate to "New Relic -> All Entities -> Redis instances" and click on the instance with name "redis" to view the instance summary. Click on "Metric explorer" to view all metrics associated with the redis instance, or use [NRQL](https://docs.newrelic.com/docs/query-your-data/explore-query-data/get-started/introduction-querying-new-relic-data/) to perform ad-hoc analysis.

## Additional notes

This example monitors a redis instance defined in [docker-compose.yaml](docker-compose.yaml), which is not receiving any load. To use in production, you'll need to modify the `.receivers.redis.endpoint` value in [collector.yaml](./collector.yaml) to point to the endpoint of your redis instance.
39 changes: 39 additions & 0 deletions other-examples/collector/redis/collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
receivers:
redis:
endpoint: ${REDIS_HOST}:${REDIS_PORT}
metrics:
# Enable redis.maxmemory optional metric
redis.maxmemory:
enabled: true

processors:
batch:
# This is required for New Relic entity synthesis. The redis receiver does not currently include any identifying attributes on the metrics it produces.
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: ${REDIS_HOST}
- action: upsert
key: server.port
value: ${REDIS_PORT}

exporters:
logging:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use debug exporter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops meant to remove this

verbosity: detailed
otlphttp:
endpoint: $NEW_RELIC_OTLP_ENDPOINT
headers:
api-key: $NEW_RELIC_API_KEY

service:
pipelines:
metrics:
receivers: [redis]
processors: [attributes/redis_metrics, batch]
exporters: [logging, otlphttp]
23 changes: 23 additions & 0 deletions other-examples/collector/redis/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: '3'
services:
redis:
image: redis:7.2-alpine
user: redis
deploy:
resources:
limits:
memory: 20M
restart: unless-stopped
ports:
- "6379"

collector:
image: otel/opentelemetry-collector-contrib:0.92.0
command: --config=/etc/otelcol/config.yaml
volumes:
- ./collector.yaml:/etc/otelcol/config.yaml
environment:
- REDIS_HOST=redis
- REDIS_PORT=6379
- NEW_RELIC_OTLP_ENDPOINT
- NEW_RELIC_API_KEY