-
Notifications
You must be signed in to change notification settings - Fork 67
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
Closed
Add redis example #608
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use debug exporter There was a problem hiding this comment. Choose a reason for hiding this commentThe 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] |
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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.