From 7b07a1d9765fd7df53aaaaa2109ccf3a712fd0d9 Mon Sep 17 00:00:00 2001 From: Zhou Date: Thu, 14 Nov 2024 19:30:52 -0800 Subject: [PATCH] Unify Application Signals export template --- .../appsignals_and_ecs_config.yaml | 30 ++++++++++++ .../sampleConfig/base_appsignals_config.yaml | 30 ++++++++++++ .../base_appsignals_fallback_config.yaml | 30 ++++++++++++ .../awsemf/appsignals_config_eks.yaml | 46 ------------------- .../awsemf/appsignals_config_generic.yaml | 5 ++ .../awsemf/appsignals_config_k8s.yaml | 46 ------------------- .../otel/exporter/awsemf/translator.go | 34 +------------- .../otel/exporter/awsemf/translator_test.go | 8 ++-- 8 files changed, 100 insertions(+), 129 deletions(-) delete mode 100644 translator/translate/otel/exporter/awsemf/appsignals_config_eks.yaml delete mode 100644 translator/translate/otel/exporter/awsemf/appsignals_config_k8s.yaml diff --git a/translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.yaml b/translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.yaml index a97027c87f..c2a36602fe 100644 --- a/translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.yaml +++ b/translator/tocwconfig/sampleConfig/appsignals_and_ecs_config.yaml @@ -32,6 +32,7 @@ exporters: - dimensions: - - Environment - Operation + - RemoteEnvironment - RemoteOperation - RemoteResourceIdentifier - RemoteResourceType @@ -39,10 +40,39 @@ exporters: - Service - - Environment - Operation + - RemoteEnvironment - RemoteOperation - RemoteService - Service - - Environment + - Operation + - RemoteOperation + - RemoteResourceIdentifier + - RemoteResourceType + - RemoteService + - Service + - - Environment + - Operation + - RemoteOperation + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteService + - Service + - - Environment + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteOperation + - RemoteResourceIdentifier + - RemoteResourceType + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteOperation - RemoteService - Service - - Environment diff --git a/translator/tocwconfig/sampleConfig/base_appsignals_config.yaml b/translator/tocwconfig/sampleConfig/base_appsignals_config.yaml index 24afc038e6..84aa3bac0f 100644 --- a/translator/tocwconfig/sampleConfig/base_appsignals_config.yaml +++ b/translator/tocwconfig/sampleConfig/base_appsignals_config.yaml @@ -32,6 +32,7 @@ exporters: - dimensions: - - Environment - Operation + - RemoteEnvironment - RemoteOperation - RemoteResourceIdentifier - RemoteResourceType @@ -39,10 +40,39 @@ exporters: - Service - - Environment - Operation + - RemoteEnvironment - RemoteOperation - RemoteService - Service - - Environment + - Operation + - RemoteOperation + - RemoteResourceIdentifier + - RemoteResourceType + - RemoteService + - Service + - - Environment + - Operation + - RemoteOperation + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteService + - Service + - - Environment + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteOperation + - RemoteResourceIdentifier + - RemoteResourceType + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteOperation - RemoteService - Service - - Environment diff --git a/translator/tocwconfig/sampleConfig/base_appsignals_fallback_config.yaml b/translator/tocwconfig/sampleConfig/base_appsignals_fallback_config.yaml index 9791f903dd..ddb31057dd 100644 --- a/translator/tocwconfig/sampleConfig/base_appsignals_fallback_config.yaml +++ b/translator/tocwconfig/sampleConfig/base_appsignals_fallback_config.yaml @@ -32,6 +32,7 @@ exporters: - dimensions: - - Environment - Operation + - RemoteEnvironment - RemoteOperation - RemoteResourceIdentifier - RemoteResourceType @@ -39,10 +40,39 @@ exporters: - Service - - Environment - Operation + - RemoteEnvironment - RemoteOperation - RemoteService - Service - - Environment + - Operation + - RemoteOperation + - RemoteResourceIdentifier + - RemoteResourceType + - RemoteService + - Service + - - Environment + - Operation + - RemoteOperation + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteService + - Service + - - Environment + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteOperation + - RemoteResourceIdentifier + - RemoteResourceType + - RemoteService + - Service + - - Environment + - RemoteEnvironment + - RemoteOperation - RemoteService - Service - - Environment diff --git a/translator/translate/otel/exporter/awsemf/appsignals_config_eks.yaml b/translator/translate/otel/exporter/awsemf/appsignals_config_eks.yaml deleted file mode 100644 index 6f24364bba..0000000000 --- a/translator/translate/otel/exporter/awsemf/appsignals_config_eks.yaml +++ /dev/null @@ -1,46 +0,0 @@ -log_group_name: "/aws/application-signals/data" -namespace: "ApplicationSignals" -middleware: agenthealth/logs -dimension_rollup_option: "NoDimensionRollup" -metric_declarations: - - dimensions: - - [Environment, Service, Operation] - - [Environment, Service] - label_matchers: - - label_names: - - Telemetry.Source - regex: '^(ServerSpan|LocalRootSpan)$' - metric_name_selectors: - - Latency - - Fault - - Error - - dimensions: - - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment] - - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, Operation, RemoteService, RemoteOperation] - - [Environment, Service, RemoteService, RemoteEnvironment] - - [Environment, Service, RemoteService] - - [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment] - - [Environment, Service, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, RemoteService, RemoteOperation] - - [Environment, Service, RemoteService, RemoteResourceIdentifier, RemoteResourceType] - - [RemoteService, RemoteResourceIdentifier, RemoteResourceType] - - [RemoteService] - label_matchers: - - label_names: - - Telemetry.Source - regex: '^(ClientSpan|ProducerSpan|ConsumerSpan)$' - metric_name_selectors: - - Latency - - Fault - - Error - - dimensions: - - [Environment, Service] - label_matchers: - - label_names: - - Telemetry.Source - regex: '^RuntimeMetric$' - metric_name_selectors: - - '^.*$' \ No newline at end of file diff --git a/translator/translate/otel/exporter/awsemf/appsignals_config_generic.yaml b/translator/translate/otel/exporter/awsemf/appsignals_config_generic.yaml index 57d10c5c6b..6f24364bba 100644 --- a/translator/translate/otel/exporter/awsemf/appsignals_config_generic.yaml +++ b/translator/translate/otel/exporter/awsemf/appsignals_config_generic.yaml @@ -15,9 +15,14 @@ metric_declarations: - Fault - Error - dimensions: + - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType] + - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment] - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType] - [Environment, Service, Operation, RemoteService, RemoteOperation] + - [Environment, Service, RemoteService, RemoteEnvironment] - [Environment, Service, RemoteService] + - [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType] + - [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment] - [Environment, Service, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType] - [Environment, Service, RemoteService, RemoteOperation] - [Environment, Service, RemoteService, RemoteResourceIdentifier, RemoteResourceType] diff --git a/translator/translate/otel/exporter/awsemf/appsignals_config_k8s.yaml b/translator/translate/otel/exporter/awsemf/appsignals_config_k8s.yaml deleted file mode 100644 index 05ea848fff..0000000000 --- a/translator/translate/otel/exporter/awsemf/appsignals_config_k8s.yaml +++ /dev/null @@ -1,46 +0,0 @@ -log_group_name: "/aws/application-signals/data" -namespace: "ApplicationSignals" -middleware: agenthealth/logs -dimension_rollup_option: "NoDimensionRollup" -metric_declarations: - - dimensions: - - [Environment, Service, Operation] - - [Environment, Service] - label_matchers: - - label_names: - - Telemetry.Source - regex: ^(ServerSpan|LocalRootSpan)$ - metric_name_selectors: - - Latency - - Fault - - Error - - dimensions: - - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteEnvironment] - - [Environment, Service, Operation, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, Operation, RemoteService, RemoteOperation] - - [Environment, Service, RemoteService, RemoteEnvironment] - - [Environment, Service, RemoteService] - - [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, RemoteService, RemoteOperation, RemoteEnvironment] - - [Environment, Service, RemoteService, RemoteOperation, RemoteResourceIdentifier, RemoteResourceType] - - [Environment, Service, RemoteService, RemoteOperation] - - [Environment, Service, RemoteService, RemoteResourceIdentifier, RemoteResourceType] - - [RemoteService, RemoteResourceIdentifier, RemoteResourceType] - - [RemoteService] - label_matchers: - - label_names: - - Telemetry.Source - regex: '^(ClientSpan|ProducerSpan|ConsumerSpan)$' - metric_name_selectors: - - Latency - - Fault - - Error - - dimensions: - - [Environment, Service] - label_matchers: - - label_names: - - Telemetry.Source - regex: '^RuntimeMetric$' - metric_name_selectors: - - '^.*$' \ No newline at end of file diff --git a/translator/translate/otel/exporter/awsemf/translator.go b/translator/translate/otel/exporter/awsemf/translator.go index 18ed408bed..0988967f52 100644 --- a/translator/translate/otel/exporter/awsemf/translator.go +++ b/translator/translate/otel/exporter/awsemf/translator.go @@ -22,7 +22,6 @@ import ( "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/extension/agenthealth" "github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/awscontainerinsight" - "github.com/aws/amazon-cloudwatch-agent/translator/util/ecsutil" ) const ( @@ -44,12 +43,6 @@ var defaultKubernetesKueueConfig string //go:embed awsemf_default_prometheus.yaml var defaultPrometheusConfig string -//go:embed appsignals_config_eks.yaml -var appSignalsConfigEks string - -//go:embed appsignals_config_k8s.yaml -var appSignalsConfigK8s string - //go:embed appsignals_config_generic.yaml var appSignalsConfigGeneric string @@ -92,7 +85,7 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) { defaultConfig := defaultGenericConfig if t.isAppSignals(c) { - defaultConfig = getAppSignalsConfig() + defaultConfig = appSignalsConfigGeneric } else if t.isCiJMX(c) { defaultConfig = defaultJmxConfig } else if isEcs(c) { @@ -163,31 +156,6 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) { return cfg, nil } -func getAppSignalsConfig() string { - ctx := context.CurrentContext() - - mode := ctx.KubernetesMode() - if mode == "" { - mode = ctx.Mode() - } - if mode == config.ModeEC2 { - if ecsutil.GetECSUtilSingleton().IsECS() { - mode = config.ModeECS - } - } - - switch mode { - case config.ModeEKS: - return appSignalsConfigEks - case config.ModeK8sEC2, config.ModeK8sOnPrem: - return appSignalsConfigK8s - case config.ModeEC2, config.ModeECS: - return appSignalsConfigGeneric - default: - return appSignalsConfigGeneric - } -} - func (t *translator) isAppSignals(conf *confmap.Conf) bool { return (t.name == common.AppSignals || t.name == common.AppSignalsFallback) && (conf.IsSet(common.AppSignalsMetrics) || conf.IsSet(common.AppSignalsTraces) || conf.IsSet(common.AppSignalsMetricsFallback) || conf.IsSet(common.AppSignalsTracesFallback)) } diff --git a/translator/translate/otel/exporter/awsemf/translator_test.go b/translator/translate/otel/exporter/awsemf/translator_test.go index b0c779198a..d6a90657f8 100644 --- a/translator/translate/otel/exporter/awsemf/translator_test.go +++ b/translator/translate/otel/exporter/awsemf/translator_test.go @@ -928,7 +928,7 @@ func TestTranslateAppSignals(t *testing.T) { "application_signals": map[string]any{}, }, }}, - want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_eks.yaml"), map[string]any{ + want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{ "local_mode": "false", "region": "us-east-1", "role_arn": "global_arn", @@ -944,7 +944,7 @@ func TestTranslateAppSignals(t *testing.T) { "application_signals": map[string]any{}, }, }}, - want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_k8s.yaml"), map[string]any{ + want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{ "local_mode": "true", "region": "us-east-1", "role_arn": "global_arn", @@ -992,7 +992,7 @@ func TestTranslateAppSignals(t *testing.T) { "app_signals": map[string]any{}, }, }}, - want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_eks.yaml"), map[string]any{ + want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{ "local_mode": "false", "region": "us-east-1", "role_arn": "global_arn", @@ -1008,7 +1008,7 @@ func TestTranslateAppSignals(t *testing.T) { "app_signals": map[string]any{}, }, }}, - want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_k8s.yaml"), map[string]any{ + want: testutil.GetConfWithOverrides(t, filepath.Join("appsignals_config_generic.yaml"), map[string]any{ "local_mode": "true", "region": "us-east-1", "role_arn": "global_arn",