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

[OTLP] add entity processor to the otlp metrics and logs pipeline #1504

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

duhminick
Copy link
Contributor

@duhminick duhminick commented Jan 16, 2025

Description of the issue

We want the ability to send entities for customers sending custom metrics via otlp: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-OpenTelemetry-metrics.html

This is currently be limited to just EKS/K8S.

Description of changes

  1. Creates an instance of entity processor specifically for OTLP
  2. Adds the newly created processor to the OTLP related pipelines by now adding the CloudWatch Logs key to the "list" of destinations
  3. Update go.mod to take in this change: Remove internal entity fields for awsemfexporter amazon-contributing/opentelemetry-collector-contrib#271

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

  1. Unit test
  2. Manual testing in an EC2 instance

Manual Testing

Using the following agent configuration:

"logs": {
    "metrics_collected": {
        "otlp": {
            "grpc_endpoint": "127.0.0.1:9999",
            "http_endpoint": "127.0.0.1:9998"
        }
    }
}
...
"metrics": {
    "metrics_collected": {
        "otlp": {
            "grpc_endpoint": "127.0.0.1:9999",
            "http_endpoint": "127.0.0.1:9998"
        }
    }
}

Output

EMF
image

Translated YAML config output for EC2

        metrics/hostOtlpMetrics:
            exporters:
                - awscloudwatch
            processors:
                - cumulativetodelta/hostOtlpMetrics
                - ec2tagger
            receivers:
                - otlp/metrics
        metrics/hostOtlpMetrics/cloudwatchlogs:
            exporters:
                - awsemf
            processors:
                - cumulativetodelta/hostOtlpMetrics/cloudwatchlogs
                - batch/hostOtlpMetrics/cloudwatchlogs
            receivers:
                - otlp/metrics
        traces/application_signals:
            exporters:
                - awsxray/application_signals
            processors:
                - resourcedetection
                - awsapplicationsignals
            receivers:
                - otlp/application_signals

Translated YAML config output for K8S

    awsentity/service/otlp:
        cluster_name: application-signals-demo
        entity_type: Service
        kubernetes_mode: EKS
        platform: ec2
...
        metrics/hostOtlpMetrics:
            exporters:
                - awscloudwatch
            processors:
                - awsentity/service/otlp
                - cumulativetodelta/hostOtlpMetrics
            receivers:
                - otlp/metrics
        metrics/hostOtlpMetrics/cloudwatchlogs:
            exporters:
                - awsemf
            processors:
                - awsentity/service/otlp
                - cumulativetodelta/hostOtlpMetrics/cloudwatchlogs
                - batch/hostOtlpMetrics/cloudwatchlogs
            receivers:
                - otlp/metrics
        traces/application_signals:
            exporters:
                - debug/application_signals
                - awsxray/application_signals
            processors:
                - resourcedetection
                - awsapplicationsignals
            receivers:
                - otlp/application_signals

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

@duhminick duhminick requested a review from a team as a code owner January 16, 2025 14:47
zhihonl
zhihonl previously approved these changes Jan 16, 2025
translator/translate/otel/pipeline/host/translator.go Outdated Show resolved Hide resolved
Paramadon
Paramadon previously approved these changes Jan 17, 2025
Copy link
Contributor

@Paramadon Paramadon left a comment

Choose a reason for hiding this comment

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

lgtm

@duhminick duhminick dismissed stale reviews from Paramadon and zhihonl via 762bf0e January 21, 2025 19:08
lisguo
lisguo previously approved these changes Jan 22, 2025
@duhminick
Copy link
Contributor Author

duhminick commented Jan 23, 2025

We've decided to just add this functionality to just K8S/EKS for the time being.

musa-asad added a commit that referenced this pull request Jan 27, 2025
…o otlp configuration, and cherry-picked otlp translation changes from #1504
validDestination := slices.Contains(supportedEntityProcessorDestinations[:], t.Destination())
// ECS is not in scope for entity association, so we only add the entity processor in non-ECS platforms
isECS := ecsutil.GetECSUtilSingleton().IsECS()
if entityProcessor != nil && currentContext.Mode() == config.ModeEC2 && !isECS && validDestination {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just make sure the mode is set to EC2 incase of EKS and k8sonEC2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On EKS, I can confirm it's set to EC2
image
As for K8sOnEC2, it will be EC2 if the configured mode is EC2. Code ref:

if configuredMode == config.ModeEC2 {
return config.ModeK8sEC2
}

receivers: []string{"nop", "other"},
processors: []string{"awsentity/service/otlp", "cumulativetodelta/hostOtlpMetrics"},
exporters: []string{"awscloudwatch"},
extensions: []string{"agenthealth/metrics", "agenthealth/statuscode"},
Copy link
Contributor

Choose a reason for hiding this comment

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

We see server extension on manual testing , why not here?

Copy link
Contributor Author

@duhminick duhminick Jan 27, 2025

Choose a reason for hiding this comment

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

I think that's just because of how the translation responsibilities are split up. So it's not really unit-testable (that is unless I did a refactor).

It's set here:

if context.CurrentContext().KubernetesMode() != "" {
pipelines.Translators.Extensions.Set(server.NewTranslator())
}

- agenthealth/metrics
- agenthealth/statuscode
- entitystore
- server
Copy link
Contributor

Choose a reason for hiding this comment

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

as we add the server extension can you query the server endpoint and check whether it is generating the pod to service map with correct values in case of just otlp in config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it works
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants