diff --git a/aws/logs_monitoring_go/internal/handling/cloudwatch.go b/aws/logs_monitoring_go/internal/handling/cloudwatch.go index d96804ed0..913eabe55 100644 --- a/aws/logs_monitoring_go/internal/handling/cloudwatch.go +++ b/aws/logs_monitoring_go/internal/handling/cloudwatch.go @@ -130,7 +130,7 @@ func (h CloudwatchHandler) newCloudwatchBaseEntry(data events.CloudwatchLogsData func (h CloudwatchHandler) newCloudwatchLogEntry(event events.CloudwatchLogsLogEvent, entry model.LogEntry) model.LogEntry { tags, service, message := extractFromMessage(event.Message) entry.Service = cmp.Or(h.cfg.Service, service, entry.Source) - entry.Tags = slices.Concat(tags, model.Tags{"service:" + entry.Service}, h.cfg.Tags) + entry.Tags = slices.Concat(tags, h.cfg.Tags) entry.Message = message entry.ID = event.ID entry.Timestamp = event.Timestamp diff --git a/aws/logs_monitoring_go/internal/handling/cloudwatch_test.go b/aws/logs_monitoring_go/internal/handling/cloudwatch_test.go index 2480ce177..bb6c4c4ab 100644 --- a/aws/logs_monitoring_go/internal/handling/cloudwatch_test.go +++ b/aws/logs_monitoring_go/internal/handling/cloudwatch_test.go @@ -70,7 +70,6 @@ func TestCloudwatchHandler_Handle(t *testing.T) { Source: "lambda", SourceCategory: "aws", Service: "lambda", - Tags: model.Tags{"service:lambda"}, Host: "/aws/lambda/testing-datadog", ID: "ev1", Timestamp: 1583425836114, @@ -101,7 +100,7 @@ func TestCloudwatchHandler_Handle(t *testing.T) { want: []model.LogEntry{ { Message: "first", Source: "lambda", SourceCategory: "aws", - Service: "lambda", Tags: model.Tags{"service:lambda"}, + Service: "lambda", Host: "/aws/lambda/fn", ID: "a1", Timestamp: 1000, Metadata: model.CloudwatchMetadata{ LambdaOrigin: model.LambdaOrigin{ARN: "arn:aws:lambda:us-east-1:123456789012:function:forwarder"}, @@ -110,7 +109,7 @@ func TestCloudwatchHandler_Handle(t *testing.T) { }, { Message: "second", Source: "lambda", SourceCategory: "aws", - Service: "lambda", Tags: model.Tags{"service:lambda"}, + Service: "lambda", Host: "/aws/lambda/fn", ID: "a2", Timestamp: 2000, Metadata: model.CloudwatchMetadata{ LambdaOrigin: model.LambdaOrigin{ARN: "arn:aws:lambda:us-east-1:123456789012:function:forwarder"}, @@ -140,7 +139,7 @@ func TestCloudwatchHandler_Handle(t *testing.T) { { Message: "hello", Source: "custom-source", SourceCategory: "aws", Service: "custom-service", - Tags: model.Tags{"service:custom-service", "env:prod", "team:infra"}, + Tags: model.Tags{"env:prod", "team:infra"}, Host: "custom-host", ID: "ev1", Timestamp: 1000, Metadata: model.CloudwatchMetadata{ LambdaOrigin: model.LambdaOrigin{ARN: "arn:aws:lambda:us-east-1:123456789012:function:forwarder"}, diff --git a/aws/logs_monitoring_go/internal/handling/s3.go b/aws/logs_monitoring_go/internal/handling/s3.go index 9e0b91bd3..955d52774 100644 --- a/aws/logs_monitoring_go/internal/handling/s3.go +++ b/aws/logs_monitoring_go/internal/handling/s3.go @@ -111,7 +111,7 @@ func (h S3Handler) newS3LogEntry(record events.S3EventRecord, message string, la entry.Metadata = metadata entry.Source = cmp.Or(h.cfg.Source, S3Source(key)) entry.Service = cmp.Or(h.cfg.Service, service, entry.Source) - entry.Tags = slices.Concat(tags, model.Tags{"service:" + entry.Service}, h.cfg.Tags) + entry.Tags = slices.Concat(tags, h.cfg.Tags) return entry } diff --git a/aws/logs_monitoring_go/internal/handling/s3_test.go b/aws/logs_monitoring_go/internal/handling/s3_test.go index 8a5a2f02b..cca3f9158 100644 --- a/aws/logs_monitoring_go/internal/handling/s3_test.go +++ b/aws/logs_monitoring_go/internal/handling/s3_test.go @@ -47,7 +47,7 @@ func TestProcessS3Record(t *testing.T) { }, cfg: testutil.EmptyConfig(), chanSize: 1, - want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", model.Tags{"service:s3"})}, + want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", nil)}, }, "multiple lines": { mockSetup: func(m *MockS3APIClient) { @@ -59,9 +59,9 @@ func TestProcessS3Record(t *testing.T) { cfg: testutil.EmptyConfig(), chanSize: 3, want: []model.LogEntry{ - wantS3Entry("line1", "s3", "s3", model.Tags{"service:s3"}), - wantS3Entry("line2", "s3", "s3", model.Tags{"service:s3"}), - wantS3Entry("line3", "s3", "s3", model.Tags{"service:s3"}), + wantS3Entry("line1", "s3", "s3", nil), + wantS3Entry("line2", "s3", "s3", nil), + wantS3Entry("line3", "s3", "s3", nil), }, }, "empty file": { @@ -91,7 +91,7 @@ func TestProcessS3Record(t *testing.T) { }, cfg: testutil.EmptyConfig(), chanSize: 1, - want: []model.LogEntry{wantS3Entry(`{"msg":"hello"}`, "s3", "myapp", model.Tags{"env:prod", "service:myapp"})}, + want: []model.LogEntry{wantS3Entry(`{"msg":"hello"}`, "s3", "myapp", model.Tags{"env:prod"})}, }, "invalid utf8 stripped": { mockSetup: func(m *MockS3APIClient) { @@ -102,7 +102,7 @@ func TestProcessS3Record(t *testing.T) { }, cfg: testutil.EmptyConfig(), chanSize: 1, - want: []model.LogEntry{wantS3Entry("helloworld", "s3", "s3", model.Tags{"service:s3"})}, + want: []model.LogEntry{wantS3Entry("helloworld", "s3", "s3", nil)}, }, "multiline groups continuation lines": { mockSetup: func(m *MockS3APIClient) { @@ -114,8 +114,8 @@ func TestProcessS3Record(t *testing.T) { cfg: &config.Config{S3MultilineLogRegex: regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)}, chanSize: 2, want: []model.LogEntry{ - wantS3Entry("2024-01-15 ERROR NullPointer\n at com.foo.Bar\n", "s3", "s3", model.Tags{"service:s3"}), - wantS3Entry("2024-01-15 INFO started", "s3", "s3", model.Tags{"service:s3"}), + wantS3Entry("2024-01-15 ERROR NullPointer\n at com.foo.Bar\n", "s3", "s3", nil), + wantS3Entry("2024-01-15 INFO started", "s3", "s3", nil), }, }, "multiline flushes at eof": { @@ -127,7 +127,7 @@ func TestProcessS3Record(t *testing.T) { }, cfg: &config.Config{S3MultilineLogRegex: regexp.MustCompile(`\d{4}-\d{2}-\d{2}`)}, chanSize: 1, - want: []model.LogEntry{wantS3Entry("2024-01-15 ERROR\n stacktrace", "s3", "s3", model.Tags{"service:s3"})}, + want: []model.LogEntry{wantS3Entry("2024-01-15 ERROR\n stacktrace", "s3", "s3", nil)}, }, "custom tags passed through": { mockSetup: func(m *MockS3APIClient) { @@ -138,7 +138,7 @@ func TestProcessS3Record(t *testing.T) { }, cfg: &config.Config{Tags: model.Tags{"env:prod", "team:aws"}}, chanSize: 1, - want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", model.Tags{"service:s3", "env:prod", "team:aws"})}, + want: []model.LogEntry{wantS3Entry("line1", "s3", "s3", model.Tags{"env:prod", "team:aws"})}, }, }