Skip to content

Commit

Permalink
feat: Increase drain max depth from 8 -> 30 (#13063)
Browse files Browse the repository at this point in the history
  • Loading branch information
benclive committed May 29, 2024
1 parent 7ffe0fb commit d0a2859
Show file tree
Hide file tree
Showing 3 changed files with 403 additions and 255 deletions.
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

0 comments on commit d0a2859

Please sign in to comment.