-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
``` | ||
|
||
* 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |