Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions common/log_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (
)

func TestLogParser(t *testing.T) {

const defaultPatternsPerLevel = 256
ch := make(chan logparser.LogEntry)
parser := logparser.NewParser(ch, nil, nil, 1*time.Second, false)
parser := logparser.NewParser(ch, nil, nil, 1*time.Second, defaultPatternsPerLevel, false)

ch <- logparser.LogEntry{Timestamp: time.Now(), Content: "INFO:root:AWS access key: AKIAUCTZOIG66SPQV67B", Level: logparser.LevelInfo}
ch <- logparser.LogEntry{Timestamp: time.Now(), Content: "INFO:root:AWS access key: AKIAIOSFODNN7EXAMPLE", Level: logparser.LevelInfo}

// wait for 10 seconds
time.Sleep(10 * time.Second)
Expand Down
21 changes: 12 additions & 9 deletions containers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"sync"
Expand Down Expand Up @@ -1782,7 +1783,7 @@ func (c *Container) runLogParser(logPath string) {
return
}
ch := make(chan logparser.LogEntry)
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId), multilineCollectorTimeout, *flags.DisableSensitiveLogParsing)
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId), multilineCollectorTimeout, *flags.LogPatternsPerContainer, *flags.DisableSensitiveLogParsing)
Comment thread
mayankpande88 marked this conversation as resolved.
reader, err := logs.NewTailReader(proc.HostPath(logPath), ch)
if err != nil {
klog.Warningln(err)
Expand All @@ -1802,7 +1803,7 @@ func (c *Container) runLogParser(logPath string) {
klog.Warningln(err)
return
}
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId), multilineCollectorTimeout, *flags.DisableSensitiveLogParsing)
parser := logparser.NewParser(ch, nil, logs.OtelLogEmitter(containerId), multilineCollectorTimeout, *flags.LogPatternsPerContainer, *flags.DisableSensitiveLogParsing)
stop := func() {
JournaldUnsubscribe(c.metadata.systemd.Unit)
}
Expand All @@ -1819,7 +1820,7 @@ func (c *Container) runLogParser(logPath string) {
delete(c.logParsers, "stdout/stderr")
}
ch := make(chan logparser.LogEntry)
parser := logparser.NewParser(ch, c.metadata.logDecoder, logs.OtelLogEmitter(containerId), multilineCollectorTimeout, *flags.DisableSensitiveLogParsing)
parser := logparser.NewParser(ch, c.metadata.logDecoder, logs.OtelLogEmitter(containerId), multilineCollectorTimeout, *flags.LogPatternsPerContainer, *flags.DisableSensitiveLogParsing)
reader, err := logs.NewTailReader(proc.HostPath(c.metadata.logPath), ch)
if err != nil {
klog.Warningln(err)
Expand Down Expand Up @@ -1995,12 +1996,14 @@ func resolveFd(pid uint32, fd uint64) (mntId string, logPath string) {
}
mntId = info.MntId

if info.Flags&os.O_WRONLY != 0 && strings.HasPrefix(info.Dest, "/var/log/") &&
!strings.HasPrefix(info.Dest, "/var/log/pods/") &&
!strings.HasPrefix(info.Dest, "/var/log/containers/") &&
!strings.HasPrefix(info.Dest, "/var/log/journal/") {

logPath = info.Dest
if info.Flags&os.O_WRONLY != 0 {
cleaned := filepath.Clean(info.Dest)
if strings.HasPrefix(cleaned, "/var/log/") &&
!strings.HasPrefix(cleaned, "/var/log/pods/") &&
!strings.HasPrefix(cleaned, "/var/log/containers/") &&
!strings.HasPrefix(cleaned, "/var/log/journal/") {
logPath = cleaned
}
}
return
}
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/jpillora/backoff v1.0.0
github.com/mdlayher/taskstats v0.0.0-20230712191918-387b3d561d14
github.com/nudgebee/logparser v0.0.0-20250610175416-3edee28c2059
github.com/nudgebee/logparser v0.0.0-20260218041043-99ea4437d928
github.com/opencontainers/runtime-spec v1.1.0
github.com/prometheus/client_golang v1.20.5
github.com/prometheus/client_model v0.6.1
Expand Down Expand Up @@ -123,6 +123,7 @@ require (
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jaeyo/go-drain3 v0.1.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVW
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jaeyo/go-drain3 v0.1.2 h1:fY21wgbwhzzaoRNSQ+6HVbpYw4KkAYjCFCoERYozIJ8=
github.com/jaeyo/go-drain3 v0.1.2/go.mod h1:6xr/0Dmq3BglAIZ5tDKiQiZvXevU1rE+qpfYZic9h9Y=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w=
Expand Down Expand Up @@ -321,8 +323,8 @@ github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nudgebee/logparser v0.0.0-20250610175416-3edee28c2059 h1:uBl8oxU66pg5348GTrIvRiNz1er9Wc7Ild+Kg0Qq+fA=
github.com/nudgebee/logparser v0.0.0-20250610175416-3edee28c2059/go.mod h1:ddmUa8en2sToRL+bBvFkuS1AHvA6Msn56v3BpLMbKoc=
github.com/nudgebee/logparser v0.0.0-20260218041043-99ea4437d928 h1:KExtH0Z1wo+yJgY2EJbZhF0YRLNcYZVASSN5gtZ513o=
github.com/nudgebee/logparser v0.0.0-20260218041043-99ea4437d928/go.mod h1:oFnM9D6YEjZzb1jy0kJ/NUkTbkZA+BgNYjpLO4n4szA=
github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
Expand Down