Skip to content

Commit

Permalink
Create aws log group and stream when not existing, and add flag for r…
Browse files Browse the repository at this point in the history
…egion
  • Loading branch information
ruffrey committed Apr 22, 2023
1 parent d3201bf commit c37d375
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var unitFileName = flag.String("unit", "", "(required) systemd unit name")
var logGroup = flag.String("log-group", "", "(required) cloudwatch log group name")
var logStream = flag.String("log-stream", "", "cloudwatch log stream name, defaults to hostname")

var awsRegion = flag.String("aws-region", "us-west-2", "aws region name")

var logBufferLimit = flag.Int("log-buffer", 10, "log buffer max limit before forward to CloudWatch")
var timeoutSeconds = flag.Int("buffer-time", 5, "log buffer max time in seconds to foward to cloudwatch regardless of buffer size")
var help = flag.Bool("h", false, "print help")
Expand All @@ -38,6 +40,7 @@ func main() {
LogGroupName: *logGroup,
LogStreamName: *logStream,
Unit: *unitFileName,
Region: *awsRegion,
}
jw := journalwatch.New(c)

Expand Down
8 changes: 8 additions & 0 deletions journalwatch/journalwatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ func (jw *JournalWatch) Start() error {

jw.cw = cloudwatchlogs.New(sess)

jw.cw.CreateLogGroup(&cloudwatchlogs.CreateLogGroupInput{
LogGroupName: &jw.config.LogGroupName,
})
jw.cw.CreateLogStream(&cloudwatchlogs.CreateLogStreamInput{
LogGroupName: &jw.config.LogGroupName,
LogStreamName: &jw.config.LogStreamName,
})

logChan := make(chan *cloudwatchlogs.InputLogEvent)
defer close(logChan)

Expand Down

0 comments on commit c37d375

Please sign in to comment.