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

perf: Gather aggregate per-line and per-tenant metrics for Drain patterns #13368

Merged
merged 6 commits into from
Jul 2, 2024

Conversation

benclive
Copy link
Contributor

@benclive benclive commented Jul 1, 2024

What this PR does / why we need it:
This PR adds metrics to help us understand what Drain is doing & to understand the shape of our log lines. These should better direct our efforts at improving pattern detection.

  • Adds two new metrics to the Drain trees (Tokens per line & state per line)
  • Adds two new dimensions (tenant & log format)

@benclive benclive requested a review from a team as a code owner July 1, 2024 16:12
return FormatUnknown
} else if line[0] == '{' && line[len(line)-1] == '}' {
return FormatJson
} else if strings.Count(line, "=") > strings.Count(line, " ")-5 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why -5 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, that number is what worked against our testdata! I think this is slightly better than only checking if the string contains an =.
If you feel strongly about making this more robust, I can rewrite it as a regex. Its only used once per stream so that shouldn't be a problem, performance wise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need something a bit more robust. There could be a lot of spaces in multiple fields ?

@pull-request-size pull-request-size bot added size/L and removed size/M labels Jul 2, 2024
@benclive benclive requested a review from cyriltovena July 2, 2024 10:41
Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cyriltovena cyriltovena merged commit bf1d6e3 into main Jul 2, 2024
60 checks passed
@cyriltovena cyriltovena deleted the benclive/gather-drain-line-metrics branch July 2, 2024 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants