Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Increase drain max depth from 8 -> 30 #13063

Merged
merged 1 commit into from
May 29, 2024
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
2 changes: 1 addition & 1 deletion pkg/pattern/drain/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func DefaultConfig() *Config {
// > message are more likely to be constants. Specifically, Drain
// > selects the next internal node by the tokens in the beginning
// > positions of the log message
LogClusterDepth: 8,
LogClusterDepth: 30,
// SimTh is basically a ratio of matching/total in the cluster.
// Cluster tokens: "foo <*> bar fred"
// Log line: "foo bar baz qux"
Expand Down
78 changes: 78 additions & 0 deletions pkg/pattern/drain/drain_benchmark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package drain

import (
"bufio"
"os"
"testing"

"github.com/stretchr/testify/require"
)

func BenchmarkDrain_TrainExtractsPatterns(b *testing.B) {
tests := []struct {
name string
drain *Drain
inputFile string
}{
{
name: `Patterns for agent logfmt logs`,
inputFile: `testdata/agent-logfmt.txt`,
},
{
name: `Patterns for ingester logfmt logs`,
inputFile: `testdata/ingester-logfmt.txt`,
},
{
name: `Patterns for Drone json logs`,
inputFile: `testdata/drone-json.txt`,
},
{
name: "Patterns for distributor logfmt logs",
inputFile: "testdata/distributor-logfmt.txt",
},
{
name: "Patterns for journald logs",
inputFile: "testdata/journald.txt",
},
{
name: "Patterns for kafka logs",
inputFile: "testdata/kafka.txt",
},
{
name: "Patterns for kubernetes logs",
inputFile: "testdata/kubernetes.txt",
},
{
name: "Patterns for vault logs",
inputFile: "testdata/vault.txt",
},
{
name: "Patterns for calico logs",
inputFile: "testdata/calico.txt",
},
}

for _, tt := range tests {
b.Run(tt.name, func(b *testing.B) {
file, err := os.Open(tt.inputFile)
require.NoError(b, err)
defer file.Close()

scanner := bufio.NewScanner(file)
var lines []string
for scanner.Scan() {
line := scanner.Text()
lines = append(lines, line)
}

b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
for _, line := range lines {
drain := New(DefaultConfig(), nil)
drain.Train(line, 0)
}
}
})
}
}
Loading
Loading