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

[processor/awsentity] Add awsentity processor into EMF pipeline #1482

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion plugins/processors/awsentity/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ func NewFactory() processor.Factory {
return processor.NewFactory(
TypeStr,
createDefaultConfig,
processor.WithMetrics(createMetricsProcessor, stability))
processor.WithMetrics(createMetricsProcessor, stability),
processor.WithLogs(createLogsProcessor, stability),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added these in factory code so awsentity can be added as a log type processor but it doesn't really do anything now

)
}

func createDefaultConfig() component.Config {
Expand All @@ -53,3 +55,23 @@ 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))
}
5 changes: 5 additions & 0 deletions plugins/processors/awsentity/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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"
Expand Down Expand Up @@ -110,6 +111,10 @@ func newAwsEntityProcessor(config *Config, logger *zap.Logger) *awsEntityProcess
}
}

func (p *awsEntityProcessor) processLogs(_ context.Context, ld plog.Logs) (plog.Logs, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function is a no-op for now since this PR is focused on adding awsentity processor to the pipeline. Will be expanded in later PRs to add entity attributes for log pipelines

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ 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
Expand Down Expand Up @@ -235,6 +238,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ processors:
awsentity/resource:
entity_type: Resource
platform: ec2
awsentity/service/emf:
entity_type: Service
platform: ec2
awsentity/service/telegraf:
entity_type: Service
platform: ec2
Expand Down Expand Up @@ -273,6 +276,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- udplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ processors:
awsentity/resource:
entity_type: Resource
platform: ec2
awsentity/service/emf:
entity_type: Service
platform: ec2
awsentity/service/telegraf:
entity_type: Service
platform: ec2
Expand Down Expand Up @@ -380,6 +383,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- udplog/emf_logs
Expand Down
4 changes: 4 additions & 0 deletions translator/tocwconfig/sampleConfig/config_with_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ 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
Expand Down Expand Up @@ -92,6 +95,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ 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
Expand Down Expand Up @@ -499,6 +502,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ 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
Expand Down Expand Up @@ -1171,6 +1174,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ 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
Expand Down Expand Up @@ -588,6 +591,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ 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
Expand Down Expand Up @@ -322,6 +325,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
4 changes: 4 additions & 0 deletions translator/tocwconfig/sampleConfig/log_ecs_metric_only.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ extensions:
mode: EC2
region_type: ACJ
processors:
awsentity/service/emf:
entity_type: Service
platform: ec2
batch/containerinsights:
metadata_cardinality_limit: 1000
send_batch_max_size: 0
Expand Down Expand Up @@ -180,6 +183,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ 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
Expand Down Expand Up @@ -491,6 +494,7 @@ service:
exporters:
- awscloudwatchlogs/emf_logs
processors:
- awsentity/service/emf
- batch/emf_logs
receivers:
- tcplog/emf_logs
Expand Down
3 changes: 2 additions & 1 deletion translator/translate/otel/pipeline/emf_logs/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"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"
Expand Down Expand Up @@ -48,7 +49,7 @@ func (t *translator) Translate(conf *confmap.Conf) (*common.ComponentTranslators
}
translators := common.ComponentTranslators{
Receivers: common.NewTranslatorMap[component.Config](),
Processors: common.NewTranslatorMap(batchprocessor.NewTranslatorWithNameAndSection(common.PipelineNameEmfLogs, common.LogsKey)), // EMF logs sit under metrics_collected in "logs"
Processors: common.NewTranslatorMap(batchprocessor.NewTranslatorWithNameAndSection(common.PipelineNameEmfLogs, common.LogsKey), awsentity.NewTranslatorWithEntityType(awsentity.Service, "emf", false)), // EMF logs sit under metrics_collected in "logs"
Exporters: common.NewTranslatorMap(awscloudwatchlogs.NewTranslatorWithName(common.PipelineNameEmfLogs)),
Extensions: common.NewTranslatorMap(agenthealth.NewTranslator(component.DataTypeLogs, []string{agenthealth.OperationPutLogEvents}),
agenthealth.NewTranslatorWithStatusCode(component.MustNewType("statuscode"), nil, true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
processors: []string{"batch/emf_logs", "awsentity/service/emf"},
exporters: []string{"awscloudwatchlogs/emf_logs"},
extensions: []string{"agenthealth/logs", "agenthealth/statuscode"},
},
Expand All @@ -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"},
processors: []string{"batch/emf_logs", "awsentity/service/emf"},
exporters: []string{"awscloudwatchlogs/emf_logs"},
extensions: []string{"agenthealth/logs", "agenthealth/statuscode"},
},
Expand All @@ -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"},
processors: []string{"batch/emf_logs", "awsentity/service/emf"},
exporters: []string{"awscloudwatchlogs/emf_logs"},
extensions: []string{"agenthealth/logs", "agenthealth/statuscode"},
},
Expand All @@ -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"},
processors: []string{"batch/emf_logs", "awsentity/service/emf"},
exporters: []string{"awscloudwatchlogs/emf_logs"},
extensions: []string{"agenthealth/logs", "agenthealth/statuscode"},
},
Expand Down
Loading