-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add guides for more otel collector use cases #15680
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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,199 @@ | ||
| --- | ||
| title: Forwarding AWS CloudWatch Logs to Sentry via the OpenTelemetry Protocol (OTLP) | ||
| sidebar_order: 100 | ||
| description: "Learn how to forward AWS CloudWatch logs to Sentry via the OpenTelemetry Protocol (OTLP)." | ||
| keywords: | ||
| ["otlp", "otel", "opentelemetry", "aws", "cloudwatch", "logs", "amazon"] | ||
| --- | ||
|
|
||
| This guide shows you how to collect AWS CloudWatch logs and forward them to Sentry using the OpenTelemetry Collector with the [AWS CloudWatch Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/awscloudwatchreceiver). | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| Before you begin, ensure you have: | ||
|
|
||
| - AWS credentials configured with permissions to read CloudWatch logs | ||
| - A Sentry project to send data to | ||
|
|
||
| ## Step 1: Install the OpenTelemetry Collector | ||
|
|
||
| The AWS CloudWatch Receiver is included in the [OpenTelemetry Collector Contrib](https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib) distribution. You'll need to download and install this version, as the standard `otelcol` binary does not include the AWS CloudWatch Receiver. | ||
|
|
||
| Download the latest `otelcol-contrib` binary from the [OpenTelemetry Collector releases page](https://github.com/open-telemetry/opentelemetry-collector-releases/releases). | ||
|
|
||
| ## Step 2: Configure AWS Credentials | ||
|
|
||
| The AWS CloudWatch Receiver uses the [AWS SDK](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html) for authentication, which supports multiple methods including credentials files and EC2 instance metadata (IMDS). | ||
|
|
||
| ### Using AWS Credentials File | ||
|
|
||
| Configure your AWS credentials using the AWS CLI: | ||
|
|
||
| ```bash | ||
| aws configure | ||
| ``` | ||
|
|
||
| This creates a credentials file at `~/.aws/credentials` with your access key and secret. | ||
|
|
||
| ### Using IAM Role (EC2) | ||
|
|
||
| If running on EC2, attach an IAM role with the `CloudWatchLogsReadOnlyAccess` policy to your instance. | ||
AbhiPrasad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Required IAM Permissions | ||
|
|
||
| Your AWS credentials need the following permissions: | ||
|
|
||
| - `logs:DescribeLogGroups` | ||
| - `logs:DescribeLogStreams` | ||
| - `logs:GetLogEvents` | ||
|
|
||
| ## Step 3: Get Your Sentry OTLP Credentials | ||
|
|
||
| You'll need your Sentry OTLP endpoint and authentication header. These can be found in your [Sentry Project Settings](https://sentry.io/settings/projects/) under **Client Keys (DSN)** > **OpenTelemetry (OTLP)**. | ||
|
|
||
| ### Logs Endpoint | ||
|
|
||
| ```bash | ||
| ___OTLP_LOGS_URL___ | ||
| ``` | ||
|
|
||
| ### Authentication Header | ||
|
|
||
| ``` | ||
| x-sentry-auth: sentry sentry_key=___PUBLIC_KEY___ | ||
| ``` | ||
|
|
||
| ## Step 4: Configure the Collector | ||
|
|
||
| Create a configuration file with the AWS CloudWatch Receiver and the OTLP HTTP exporter configured to send logs to Sentry. | ||
|
|
||
| For additional configuration options, see the [AWS CloudWatch Receiver Documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/awscloudwatchreceiver). | ||
|
|
||
| ### Collect All Log Groups (Autodiscover) | ||
|
|
||
| This configuration automatically discovers and collects logs from all CloudWatch log groups: | ||
|
|
||
| ```yaml {filename:config.yaml} | ||
| receivers: | ||
| awscloudwatch: | ||
| region: us-east-1 | ||
| logs: | ||
| poll_interval: 1m | ||
|
|
||
| processors: | ||
| batch: | ||
| send_batch_size: 1024 | ||
| send_batch_max_size: 2048 | ||
| timeout: "1s" | ||
|
|
||
| exporters: | ||
| otlphttp/sentry: | ||
| logs_endpoint: ___OTLP_LOGS_URL___ | ||
| headers: | ||
| x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___" | ||
| compression: gzip | ||
| encoding: proto | ||
|
|
||
| service: | ||
| pipelines: | ||
| logs: | ||
| receivers: | ||
| - awscloudwatch | ||
| processors: | ||
| - batch | ||
| exporters: | ||
| - otlphttp/sentry | ||
| ``` | ||
|
|
||
| ### Collect Specific Log Groups by Prefix | ||
|
|
||
| This configuration discovers log groups matching a specific prefix, useful for collecting logs from specific AWS services like EKS or Lambda: | ||
|
|
||
| ```yaml {filename:config.yaml} | ||
| receivers: | ||
| awscloudwatch: | ||
| region: us-east-1 | ||
| logs: | ||
| poll_interval: 1m | ||
| groups: | ||
| autodiscover: | ||
| limit: 100 | ||
| prefix: /aws/lambda/ | ||
|
|
||
| processors: | ||
| batch: | ||
| send_batch_size: 1024 | ||
| send_batch_max_size: 2048 | ||
| timeout: "1s" | ||
|
|
||
| exporters: | ||
| otlphttp/sentry: | ||
| logs_endpoint: ___OTLP_LOGS_URL___ | ||
| headers: | ||
| x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___" | ||
| compression: gzip | ||
| encoding: proto | ||
|
|
||
| service: | ||
| pipelines: | ||
| logs: | ||
| receivers: | ||
| - awscloudwatch | ||
| processors: | ||
| - batch | ||
| exporters: | ||
| - otlphttp/sentry | ||
| ``` | ||
|
|
||
| ### Collect Named Log Groups | ||
|
|
||
| This configuration collects logs from specific, named log groups: | ||
|
|
||
| ```yaml {filename:config.yaml} | ||
| receivers: | ||
| awscloudwatch: | ||
| region: us-east-1 | ||
| logs: | ||
| poll_interval: 1m | ||
| groups: | ||
| named: | ||
| /aws/lambda/my-function: | ||
| /aws/eks/my-cluster/cluster: | ||
|
|
||
| processors: | ||
| batch: | ||
| send_batch_size: 1024 | ||
| send_batch_max_size: 2048 | ||
| timeout: "1s" | ||
|
|
||
| exporters: | ||
| otlphttp/sentry: | ||
| logs_endpoint: ___OTLP_LOGS_URL___ | ||
| headers: | ||
| x-sentry-auth: "sentry sentry_key=___PUBLIC_KEY___" | ||
| compression: gzip | ||
| encoding: proto | ||
|
|
||
| service: | ||
| pipelines: | ||
| logs: | ||
| receivers: | ||
| - awscloudwatch | ||
| processors: | ||
| - batch | ||
| exporters: | ||
| - otlphttp/sentry | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| - Verify your AWS credentials are correctly configured and have the required permissions | ||
| - Ensure the specified AWS region matches where your CloudWatch log groups are located | ||
| - Check that the log group names or prefixes match existing CloudWatch log groups | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| - [AWS CloudWatch Receiver Documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/awscloudwatchreceiver) | ||
| - [AWS SDK Authentication](https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html) | ||
| - [Sentry OpenTelemetry Collector Configuration](/product/drains/integration/opentelemetry-collector/) | ||
| - [Sentry Logs](/product/explore/logs/) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.