Skip to content

Commit

Permalink
address PR suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
ymtaye committed Oct 16, 2023
1 parent 7c3a189 commit 3201655
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions plugins/inputs/logfile/fileconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,22 +150,22 @@ func TestTimestampParserDefault(t *testing.T) {
TimezoneLoc: timezoneLoc}

// make sure layout is compatible for "Sep 9", "Sep 9" , "Sep 09", "Sep 09" options
logEntry := fmt.Sprintf("Sep 9 02:00:43 ip-10-4-213-132 sudo: vtayyare : TTY=pts/0 ; PWD=/home/vtayyare ; USER=root ; COMMAND=/bin/cat /var/log/secure\n")
logEntry := fmt.Sprintf("Sep 9 02:00:43 ip-10-4-213-132 \n")
timestamp := fileConfig.timestampFromLogLine(logEntry)
assert.Equal(t, 02, timestamp.Hour())
assert.Equal(t, 00, timestamp.Minute())

logEntry = fmt.Sprintf("Sep 9 02:00:43 ip-10-4-213-132 sudo: vtayyare : TTY=pts/0 ; PWD=/home/vtayyare ; USER=root ; COMMAND=/bin/cat /var/log/secure\n")
logEntry = fmt.Sprintf("Sep 9 02:00:43 ip-10-4-213-132 \n")
timestamp = fileConfig.timestampFromLogLine(logEntry)
assert.Equal(t, 02, timestamp.Hour())
assert.Equal(t, 00, timestamp.Minute())

logEntry = fmt.Sprintf("Sep 09 02:00:43 ip-10-4-213-132 sudo: vtayyare : TTY=pts/0 ; PWD=/home/vtayyare ; USER=root ; COMMAND=/bin/cat /var/log/secure\n")
logEntry = fmt.Sprintf("Sep 09 02:00:43 ip-10-4-213-132 \n")
timestamp = fileConfig.timestampFromLogLine(logEntry)
assert.Equal(t, 02, timestamp.Hour())
assert.Equal(t, 00, timestamp.Minute())

logEntry = fmt.Sprintf("Sep 09 02:00:43 ip-10-4-213-132 sudo: vtayyare : TTY=pts/0 ; PWD=/home/vtayyare ; USER=root ; COMMAND=/bin/cat /var/log/secure\n")
logEntry = fmt.Sprintf("Sep 09 02:00:43 ip-10-4-213-132 \n")
timestamp = fileConfig.timestampFromLogLine(logEntry)
assert.Equal(t, 02, timestamp.Hour())
assert.Equal(t, 00, timestamp.Minute())
Expand Down
10 changes: 5 additions & 5 deletions plugins/outputs/cloudwatchlogs/pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
)

const (
reqSizeLimit = 1024 * 1024
reqEventsLimit = 10000
elaspedPeriod = 5 * 24 * time.Hour
reqSizeLimit = 1024 * 1024
reqEventsLimit = 10000
logWarnInterval = 1 * 24 * time.Hour
)

var (
Expand Down Expand Up @@ -417,8 +417,8 @@ func (p *pusher) convertEvent(e logs.LogEvent) *cloudwatchlogs.InputLogEvent {
t = p.lastValidTime
if !p.lastUpdateTime.IsZero() {
// Check when timestamp has an interval of 5 days.
if time.Since(p.lastUpdateTime) > elaspedPeriod {
p.Log.Warnf("Unable to parse timestamp, using last valid timestamp %v: which is older than 5 days for log group %v: ", p.lastValidTime, p.Group)
if time.Since(p.lastUpdateTime) > logWarnInterval {
p.Log.Warnf("Unable to parse timestamp, using last valid timestamp %v: which is at least older by 1 day for log group %v: ", p.lastValidTime, p.Group)
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,6 @@ func applyRule1(t *testing.T, buf string) interface{} {
return val
}

// stdNumMonth // "_1" //%-m
// stdDay // "_2" //%-d
// -hour:-minute:-seconds does not work for golang parser.
func TestTimestampFormat_NonZeroPadding(t *testing.T) {
f := new(FileConfig)
Expand Down

0 comments on commit 3201655

Please sign in to comment.