Skip to content

Commit 7b792f7

Browse files
committed
Adjust prefix of logs; adjust default flags
1 parent 43ee476 commit 7b792f7

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ build: build-arm64 build-x86
44

55
build-arm64:
66
env CGO_ENABLED=1 GOOS=linux GOARCH=arm64 CC=aarch64-linux-gnu-gcc go build -o out/journalwatch-arm64 ./cmd
7+
chmod +x out/journalwatch-arm64
78

89
build-x86:
910
env CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC=x86_64-linux-gnu-gcc go build -o out/journalwatch-x86 ./cmd
11+
chmod +x out/journalwatch-x86
1012

1113
clean:
1214
rm -f out/*

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ journalwatch -h
1313
-aws-region string
1414
aws region name (default "us-west-2")
1515
-buffer-time int
16-
log buffer max time in seconds to foward to cloudwatch regardless of buffer size (default 5)
16+
log buffer max time in seconds to foward to cloudwatch regardless of buffer size (default 8)
1717
-h print help
1818
-log-buffer int
19-
log buffer max limit before forward to CloudWatch (default 10)
19+
log buffer max limit before forward to CloudWatch (default 20)
2020
-log-group string
2121
(required) cloudwatch log group name
2222
-log-stream string

cmd/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ var logStream = flag.String("log-stream", "", "cloudwatch log stream name, defau
1414

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

17-
var logBufferLimit = flag.Int("log-buffer", 10, "log buffer max limit before forward to CloudWatch")
18-
var timeoutSeconds = flag.Int("buffer-time", 5, "log buffer max time in seconds to foward to cloudwatch regardless of buffer size")
17+
var logBufferLimit = flag.Int("log-buffer", 20, "log buffer max limit before forward to CloudWatch")
18+
var timeoutSeconds = flag.Int("buffer-time", 8, "log buffer max time in seconds to foward to cloudwatch regardless of buffer size")
1919
var help = flag.Bool("h", false, "print help")
2020

2121
func main() {

journalwatch/journalwatch.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/coreos/go-systemd/v22/sdjournal"
88
"log"
99
"os"
10+
"strings"
1011
"sync"
1112
"time"
1213
)
@@ -115,7 +116,7 @@ func (jw *JournalWatch) readJournal(journal *sdjournal.Journal, logChan chan<- *
115116
t := time.Unix(0, int64(ts)*1000)
116117

117118
event := &cloudwatchlogs.InputLogEvent{
118-
Message: aws.String(msg),
119+
Message: aws.String(strings.Replace(msg, "MESSAGE=", "", 1)),
119120
Timestamp: aws.Int64(t.UnixNano() / int64(time.Millisecond)),
120121
}
121122

0 commit comments

Comments
 (0)