From d9a1bc686ea74b9a38b99325288b9747910ccdf9 Mon Sep 17 00:00:00 2001 From: Zhihong Lin Date: Tue, 7 Jan 2025 14:15:50 -0500 Subject: [PATCH] Revert "[processor/awsentity] Add awsentity processor into EMF pipeline (#1482)" This reverts commit dfd207047018b0d7afe1905bdd747790241c0cfa. --- plugins/processors/awsentity/factory.go | 24 +------------------ plugins/processors/awsentity/factory_test.go | 4 ++-- plugins/processors/awsentity/processor.go | 5 ---- .../base_container_insights_config.yaml | 4 ---- .../sampleConfig/complete_darwin_config.yaml | 4 ---- .../sampleConfig/complete_linux_config.yaml | 4 ---- .../sampleConfig/complete_windows_config.yaml | 4 ---- .../sampleConfig/config_with_env.yaml | 4 ---- .../emf_and_kubernetes_config.yaml | 4 ---- .../emf_and_kubernetes_with_gpu_config.yaml | 4 ---- .../emf_and_kubernetes_with_kueue_config.yaml | 4 ---- .../kueue_container_insights_config.yaml | 4 ---- .../logs_and_kubernetes_config.yaml | 4 ---- .../otel/pipeline/emf_logs/translator.go | 6 ----- .../otel/pipeline/emf_logs/translator_test.go | 8 +++---- 15 files changed, 7 insertions(+), 80 deletions(-) diff --git a/plugins/processors/awsentity/factory.go b/plugins/processors/awsentity/factory.go index caf4696c87..32887ffa6a 100644 --- a/plugins/processors/awsentity/factory.go +++ b/plugins/processors/awsentity/factory.go @@ -26,9 +26,7 @@ func NewFactory() processor.Factory { return processor.NewFactory( TypeStr, createDefaultConfig, - processor.WithMetrics(createMetricsProcessor, stability), - processor.WithLogs(createLogsProcessor, stability), - ) + processor.WithMetrics(createMetricsProcessor, stability)) } func createDefaultConfig() component.Config { @@ -55,23 +53,3 @@ func createMetricsProcessor( metricsProcessor.processMetrics, processorhelper.WithCapabilities(processorCapabilities)) } - -func createLogsProcessor( - ctx context.Context, - set processor.Settings, - cfg component.Config, - nextConsumer consumer.Logs, -) (processor.Logs, error) { - processorConfig, ok := cfg.(*Config) - if !ok { - return nil, errors.New("configuration parsing error") - } - logProcessor := newAwsEntityProcessor(processorConfig, set.Logger) - return processorhelper.NewLogsProcessor( - ctx, - set, - cfg, - nextConsumer, - logProcessor.processLogs, - processorhelper.WithCapabilities(processorCapabilities)) -} diff --git a/plugins/processors/awsentity/factory_test.go b/plugins/processors/awsentity/factory_test.go index e98c61b26d..a00799bc55 100644 --- a/plugins/processors/awsentity/factory_test.go +++ b/plugins/processors/awsentity/factory_test.go @@ -40,6 +40,6 @@ func TestCreateProcessor(t *testing.T) { assert.NotNil(t, mProcessor) lProcessor, err := factory.CreateLogsProcessor(context.Background(), setting, cfg, consumertest.NewNop()) - assert.NoError(t, err) - assert.NotNil(t, lProcessor) + assert.Equal(t, err, component.ErrDataTypeIsNotSupported) + assert.Nil(t, lProcessor) } diff --git a/plugins/processors/awsentity/processor.go b/plugins/processors/awsentity/processor.go index b39f4ec8c1..bd1a63b079 100644 --- a/plugins/processors/awsentity/processor.go +++ b/plugins/processors/awsentity/processor.go @@ -9,7 +9,6 @@ import ( "github.com/go-playground/validator/v10" "go.opentelemetry.io/collector/pdata/pcommon" - "go.opentelemetry.io/collector/pdata/plog" "go.opentelemetry.io/collector/pdata/pmetric" semconv "go.opentelemetry.io/collector/semconv/v1.22.0" "go.uber.org/zap" @@ -111,10 +110,6 @@ func newAwsEntityProcessor(config *Config, logger *zap.Logger) *awsEntityProcess } } -func (p *awsEntityProcessor) processLogs(_ context.Context, ld plog.Logs) (plog.Logs, error) { - return ld, nil -} - func (p *awsEntityProcessor) processMetrics(_ context.Context, md pmetric.Metrics) (pmetric.Metrics, error) { // Get the following metric attributes from the EntityStore: PlatformType, EC2.InstanceId, EC2.AutoScalingGroup diff --git a/translator/tocwconfig/sampleConfig/base_container_insights_config.yaml b/translator/tocwconfig/sampleConfig/base_container_insights_config.yaml index 5002e989b6..4df5992b20 100644 --- a/translator/tocwconfig/sampleConfig/base_container_insights_config.yaml +++ b/translator/tocwconfig/sampleConfig/base_container_insights_config.yaml @@ -159,9 +159,6 @@ extensions: mode: ec2 region: us-east-1 processors: - awsentity/service/emf: - entity_type: Service - platform: ec2 batch/containerinsights: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -238,7 +235,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/complete_darwin_config.yaml b/translator/tocwconfig/sampleConfig/complete_darwin_config.yaml index 04253829b9..cb9b62b5d7 100644 --- a/translator/tocwconfig/sampleConfig/complete_darwin_config.yaml +++ b/translator/tocwconfig/sampleConfig/complete_darwin_config.yaml @@ -105,9 +105,6 @@ processors: awsentity/resource: entity_type: Resource platform: ec2 - awsentity/service/emf: - entity_type: Service - platform: ec2 awsentity/service/telegraf: entity_type: Service platform: ec2 @@ -276,7 +273,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - udplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/complete_linux_config.yaml b/translator/tocwconfig/sampleConfig/complete_linux_config.yaml index 5ee86838e1..6105f937bc 100644 --- a/translator/tocwconfig/sampleConfig/complete_linux_config.yaml +++ b/translator/tocwconfig/sampleConfig/complete_linux_config.yaml @@ -111,9 +111,6 @@ processors: awsentity/resource: entity_type: Resource platform: ec2 - awsentity/service/emf: - entity_type: Service - platform: ec2 awsentity/service/telegraf: entity_type: Service platform: ec2 @@ -383,7 +380,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - udplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/complete_windows_config.yaml b/translator/tocwconfig/sampleConfig/complete_windows_config.yaml index 0a7fb5c98f..e7fa12f152 100644 --- a/translator/tocwconfig/sampleConfig/complete_windows_config.yaml +++ b/translator/tocwconfig/sampleConfig/complete_windows_config.yaml @@ -105,9 +105,6 @@ processors: awsentity/resource: entity_type: Resource platform: ec2 - awsentity/service/emf: - entity_type: Service - platform: ec2 awsentity/service/telegraf: entity_type: Service platform: ec2 @@ -263,7 +260,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - udplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/config_with_env.yaml b/translator/tocwconfig/sampleConfig/config_with_env.yaml index 82dddd5788..40307cc324 100644 --- a/translator/tocwconfig/sampleConfig/config_with_env.yaml +++ b/translator/tocwconfig/sampleConfig/config_with_env.yaml @@ -50,9 +50,6 @@ extensions: mode: ec2 region: ${ENV_REGION} processors: - awsentity/service/emf: - entity_type: Service - platform: ec2 batch/emf_logs: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -95,7 +92,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/emf_and_kubernetes_config.yaml b/translator/tocwconfig/sampleConfig/emf_and_kubernetes_config.yaml index 766c73e1fa..8a0d8fc3e2 100644 --- a/translator/tocwconfig/sampleConfig/emf_and_kubernetes_config.yaml +++ b/translator/tocwconfig/sampleConfig/emf_and_kubernetes_config.yaml @@ -411,9 +411,6 @@ extensions: region: us-east-1 shared_credential_file: /root/.aws/credentials processors: - awsentity/service/emf: - entity_type: Service - platform: onPremise batch/containerinsights: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -502,7 +499,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_gpu_config.yaml b/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_gpu_config.yaml index 961f1ea924..d70f0580c3 100644 --- a/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_gpu_config.yaml +++ b/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_gpu_config.yaml @@ -669,9 +669,6 @@ extensions: region: us-east-1 shared_credential_file: /root/.aws/credentials processors: - awsentity/service/emf: - entity_type: Service - platform: onPremise batch/containerinsights: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -1174,7 +1171,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_kueue_config.yaml b/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_kueue_config.yaml index 31d2db9286..f59e0a6639 100644 --- a/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_kueue_config.yaml +++ b/translator/tocwconfig/sampleConfig/emf_and_kubernetes_with_kueue_config.yaml @@ -491,9 +491,6 @@ extensions: region: us-east-1 shared_credential_file: /root/.aws/credentials processors: - awsentity/service/emf: - entity_type: Service - platform: onPremise batch/containerinsights: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -591,7 +588,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/kueue_container_insights_config.yaml b/translator/tocwconfig/sampleConfig/kueue_container_insights_config.yaml index 42ff679f8b..afc2bc77ed 100644 --- a/translator/tocwconfig/sampleConfig/kueue_container_insights_config.yaml +++ b/translator/tocwconfig/sampleConfig/kueue_container_insights_config.yaml @@ -237,9 +237,6 @@ extensions: mode: ec2 region: us-east-1 processors: - awsentity/service/emf: - entity_type: Service - platform: ec2 batch/containerinsights: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -325,7 +322,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/tocwconfig/sampleConfig/logs_and_kubernetes_config.yaml b/translator/tocwconfig/sampleConfig/logs_and_kubernetes_config.yaml index 0ff9a6b06d..46216e4031 100644 --- a/translator/tocwconfig/sampleConfig/logs_and_kubernetes_config.yaml +++ b/translator/tocwconfig/sampleConfig/logs_and_kubernetes_config.yaml @@ -405,9 +405,6 @@ extensions: mode: ec2 region: us-east-1 processors: - awsentity/service/emf: - entity_type: Service - platform: ec2 batch/containerinsights: metadata_cardinality_limit: 1000 send_batch_max_size: 0 @@ -494,7 +491,6 @@ service: exporters: - awscloudwatchlogs/emf_logs processors: - - awsentity/service/emf - batch/emf_logs receivers: - tcplog/emf_logs diff --git a/translator/translate/otel/pipeline/emf_logs/translator.go b/translator/translate/otel/pipeline/emf_logs/translator.go index 7172e6df98..c155b8176c 100644 --- a/translator/translate/otel/pipeline/emf_logs/translator.go +++ b/translator/translate/otel/pipeline/emf_logs/translator.go @@ -9,15 +9,12 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/confmap" - "github.com/aws/amazon-cloudwatch-agent/translator/context" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/exporter/awscloudwatchlogs" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/extension/agenthealth" - "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/processor/awsentity" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/processor/batchprocessor" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/tcplog" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/udplog" - "github.com/aws/amazon-cloudwatch-agent/translator/util/ecsutil" ) var ( @@ -57,9 +54,6 @@ func (t *translator) Translate(conf *confmap.Conf) (*common.ComponentTranslators agenthealth.NewTranslatorWithStatusCode(component.MustNewType("statuscode"), nil, true), ), } - if !(context.CurrentContext().RunInContainer() && ecsutil.GetECSUtilSingleton().IsECS()) { - translators.Processors.Set(awsentity.NewTranslatorWithEntityType(awsentity.Service, "emf", false)) - } if serviceAddress, ok := common.GetString(conf, serviceAddressEMFKey); ok { if strings.Contains(serviceAddress, common.Udp) { translators.Receivers.Set(udplog.NewTranslatorWithName(common.PipelineNameEmfLogs)) diff --git a/translator/translate/otel/pipeline/emf_logs/translator_test.go b/translator/translate/otel/pipeline/emf_logs/translator_test.go index 5ff0b97af3..2354ca057e 100644 --- a/translator/translate/otel/pipeline/emf_logs/translator_test.go +++ b/translator/translate/otel/pipeline/emf_logs/translator_test.go @@ -46,7 +46,7 @@ func TestTranslator(t *testing.T) { want: &want{ pipelineType: "logs/emf_logs", receivers: []string{"tcplog/emf_logs", "udplog/emf_logs"}, - processors: []string{"batch/emf_logs", "awsentity/service/emf"}, + processors: []string{"batch/emf_logs"}, exporters: []string{"awscloudwatchlogs/emf_logs"}, extensions: []string{"agenthealth/logs", "agenthealth/statuscode"}, }, @@ -62,7 +62,7 @@ func TestTranslator(t *testing.T) { want: &want{ pipelineType: "logs/emf_logs", receivers: []string{"tcplog/emf_logs", "udplog/emf_logs"}, - processors: []string{"batch/emf_logs", "awsentity/service/emf"}, + processors: []string{"batch/emf_logs"}, exporters: []string{"awscloudwatchlogs/emf_logs"}, extensions: []string{"agenthealth/logs", "agenthealth/statuscode"}, }, @@ -80,7 +80,7 @@ func TestTranslator(t *testing.T) { want: &want{ pipelineType: "logs/emf_logs", receivers: []string{"udplog/emf_logs"}, - processors: []string{"batch/emf_logs", "awsentity/service/emf"}, + processors: []string{"batch/emf_logs"}, exporters: []string{"awscloudwatchlogs/emf_logs"}, extensions: []string{"agenthealth/logs", "agenthealth/statuscode"}, }, @@ -98,7 +98,7 @@ func TestTranslator(t *testing.T) { want: &want{ pipelineType: "logs/emf_logs", receivers: []string{"tcplog/emf_logs"}, - processors: []string{"batch/emf_logs", "awsentity/service/emf"}, + processors: []string{"batch/emf_logs"}, exporters: []string{"awscloudwatchlogs/emf_logs"}, extensions: []string{"agenthealth/logs", "agenthealth/statuscode"}, },