From fa205eb2ea2cf1fd7d5d08611c2b30d1b57d6d3f Mon Sep 17 00:00:00 2001 From: Dinakar Chappa Date: Tue, 29 Aug 2023 02:32:00 -0400 Subject: [PATCH] Makes necessary changes for updated CreateLogGroup API calls (#466) --- plugins/outputs/cloudwatchlogs/pusher.go | 4 ++-- test/logs/logs_test.go | 16 ++++++++-------- test/logs/testdata/logs_config_basic.json | 4 ++-- tool/util/util.go | 2 +- .../files/collect_list/collect_list_test.go | 2 +- .../files/collect_list/ruleLogGroupClass_test.go | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/plugins/outputs/cloudwatchlogs/pusher.go b/plugins/outputs/cloudwatchlogs/pusher.go index 5f1b127be7..8a7e08c676 100644 --- a/plugins/outputs/cloudwatchlogs/pusher.go +++ b/plugins/outputs/cloudwatchlogs/pusher.go @@ -344,8 +344,8 @@ func (p *pusher) createLogGroupAndStream() error { p.Log.Debugf("creating stream fail due to : %v", err) if awsErr, ok := err.(awserr.Error); ok && awsErr.Code() == cloudwatchlogs.ErrCodeResourceNotFoundException { _, err = p.Service.CreateLogGroup(&cloudwatchlogs.CreateLogGroupInput{ - LogGroupName: &p.Group, - LogGroupTier: &p.Class, + LogGroupName: &p.Group, + LogGroupClass: &p.Class, }) // attempt to create stream again if group created successfully. diff --git a/test/logs/logs_test.go b/test/logs/logs_test.go index 86bdcfea09..2831afb0cc 100644 --- a/test/logs/logs_test.go +++ b/test/logs/logs_test.go @@ -38,7 +38,7 @@ type input struct { testName string configPath string logGroupName string - logGroupClass types.LogGroupTier + logGroupClass types.LogGroupClass } var testParameters = []input{ @@ -46,19 +46,19 @@ var testParameters = []input{ testName: "Standard log config", configPath: "testdata/logs_config.json", logGroupName: instanceId, - logGroupClass: types.LogGroupTierStandard, + logGroupClass: types.LogGroupClassStandard, }, { testName: "Standard log config with standard class specification", configPath: "testdata/logs_config_standard.json", logGroupName: instanceId, - logGroupClass: types.LogGroupTierStandard, + logGroupClass: types.LogGroupClassStandard, }, - { //TODO update all naming from basic to essentials once SDK changes are available - testName: "Standard log config with basic class specification", + { + testName: "Standard log config with essentials class specification", configPath: "testdata/logs_config_basic.json", - logGroupName: instanceId + "-basic", - logGroupClass: types.LogGroupTierBasic, + logGroupName: instanceId + "-essentials", + logGroupClass: types.LogGroupClassEssentials, }, } @@ -108,7 +108,7 @@ func validateLogGroupExistence(param input) (bool, error) { // check CWL to ensure we got the expected log groups describeLogGroupInput := cloudwatchlogs.DescribeLogGroupsInput{ LogGroupNamePrefix: aws.String(param.logGroupName), - LogGroupTier: param.logGroupClass, + LogGroupClass: param.logGroupClass, } describeLogGroupOutput, err := CwlClient.DescribeLogGroups(ctx, &describeLogGroupInput) diff --git a/test/logs/testdata/logs_config_basic.json b/test/logs/testdata/logs_config_basic.json index 7d68e425b9..b6fa1da2b0 100644 --- a/test/logs/testdata/logs_config_basic.json +++ b/test/logs/testdata/logs_config_basic.json @@ -9,10 +9,10 @@ "collect_list": [ { "file_path": "/tmp/test.log", - "log_group_name": "{instance_id}-basic", + "log_group_name": "{instance_id}-essentials", "log_stream_name": "{instance_id}", "timezone": "UTC", - "log_group_class": "basic" + "log_group_class": "essentials" } ] } diff --git a/tool/util/util.go b/tool/util/util.go index 748c5d4c33..9304d973f4 100644 --- a/tool/util/util.go +++ b/tool/util/util.go @@ -41,7 +41,7 @@ const ( MapKeyMeasurement = "measurement" StandardLogGroupClass = "STANDARD" - EssentialsLogGroupClass = "BASIC" + EssentialsLogGroupClass = "ESSENTIALS" ) func CurOS() string { diff --git a/translator/translate/logs/logs_collected/files/collect_list/collect_list_test.go b/translator/translate/logs/logs_collected/files/collect_list/collect_list_test.go index ed9d928a28..d4c5952fdb 100644 --- a/translator/translate/logs/logs_collected/files/collect_list/collect_list_test.go +++ b/translator/translate/logs/logs_collected/files/collect_list/collect_list_test.go @@ -865,7 +865,7 @@ func TestConflictingLogGroupClass(t *testing.T) { "file_path":"path1", "log_group_name":"test1", "retention_in_days":3, - "log_group_class": "basic" + "log_group_class": "essentials" } ] diff --git a/translator/translate/logs/logs_collected/files/collect_list/ruleLogGroupClass_test.go b/translator/translate/logs/logs_collected/files/collect_list/ruleLogGroupClass_test.go index 302bc94c86..fa0cb85f52 100644 --- a/translator/translate/logs/logs_collected/files/collect_list/ruleLogGroupClass_test.go +++ b/translator/translate/logs/logs_collected/files/collect_list/ruleLogGroupClass_test.go @@ -16,7 +16,7 @@ func TestApplyLogGroupClassRule(t *testing.T) { r := new(LogGroupClass) var input interface{} e := json.Unmarshal([]byte(`{ - "log_group_class": "basic" + "log_group_class": "essentials" }`), &input) if e == nil { actualReturnKey, actualReturnVal := r.ApplyRule(input)