Skip to content

Commit

Permalink
Makes necessary changes for updated CreateLogGroup API calls (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
dchappa authored Aug 29, 2023
1 parent 631a1db commit fa205eb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions plugins/outputs/cloudwatchlogs/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions test/logs/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ type input struct {
testName string
configPath string
logGroupName string
logGroupClass types.LogGroupTier
logGroupClass types.LogGroupClass
}

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,
},
}

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/logs/testdata/logs_config_basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion tool/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
MapKeyMeasurement = "measurement"

StandardLogGroupClass = "STANDARD"
EssentialsLogGroupClass = "BASIC"
EssentialsLogGroupClass = "ESSENTIALS"
)

func CurOS() string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fa205eb

Please sign in to comment.