Skip to content

Commit f2a4019

Browse files
committed
add condition when log_group_name_prefix is not given
1 parent bfc2817 commit f2a4019

File tree

1 file changed

+18
-13
lines changed
  • x-pack/filebeat/input/awscloudwatch

1 file changed

+18
-13
lines changed

x-pack/filebeat/input/awscloudwatch/input.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,25 +133,30 @@ func NewInput(cfg *common.Config, connector channel.Connector, context input.Con
133133
func (in *awsCloudWatchInput) Run() {
134134
cwConfig := awscommon.EnrichAWSConfigWithEndpoint(in.config.AwsConfig.Endpoint, "cloudwatchlogs", in.config.RegionName, in.awsConfig)
135135
svc := cloudwatchlogs.New(cwConfig)
136+
137+
var logGroupNames []string
138+
var err error
136139
if in.config.LogGroupNamePrefix != "" {
137-
logGroupNames, err := in.getLogGroupNames(svc)
140+
logGroupNames, err = in.getLogGroupNames(svc)
138141
if err != nil {
139142
in.logger.Error("getLogGroupNames failed: ", err)
140143
return
141144
}
145+
} else {
146+
logGroupNames = []string{in.config.LogGroupName}
147+
}
142148

143-
for _, logGroup := range logGroupNames {
144-
in.config.LogGroupName = logGroup
145-
in.workerOnce.Do(func() {
146-
in.workerWg.Add(1)
147-
go func() {
148-
in.logger.Infof("aws-cloudwatch input worker for log group: '%v' has started", in.config.LogGroupName)
149-
defer in.logger.Infof("aws-cloudwatch input worker for log group '%v' has stopped.", in.config.LogGroupName)
150-
defer in.workerWg.Done()
151-
in.run()
152-
}()
153-
})
154-
}
149+
for _, logGroup := range logGroupNames {
150+
in.config.LogGroupName = logGroup
151+
in.workerOnce.Do(func() {
152+
in.workerWg.Add(1)
153+
go func() {
154+
in.logger.Infof("aws-cloudwatch input worker for log group: '%v' has started", in.config.LogGroupName)
155+
defer in.logger.Infof("aws-cloudwatch input worker for log group '%v' has stopped.", in.config.LogGroupName)
156+
defer in.workerWg.Done()
157+
in.run()
158+
}()
159+
})
155160
}
156161
}
157162

0 commit comments

Comments
 (0)