-
Notifications
You must be signed in to change notification settings - Fork 251
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
Add windowsevent stage loki process #2545
base: main
Are you sure you want to change the base?
Conversation
💻 Deploy preview available: https://deploy-preview-alloy-2545-zb444pucvq-vp.a.run.app/docs/alloy/latest/ |
7c88f59
to
24b6f7b
Compare
continue | ||
} | ||
|
||
ek := parts[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to sanitize here? Had to follow the logic to make sure the key prefix also ultimately gets sanitized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it's better not to sanitize the prefix by itself because the sanitization process checks for duplicates and it would add an "_extracted" prefix that's not needed on the prefix in case of collision.
For example:
- the key "Subject" already exists in the map
- the prefix "Subject" is parsed.
- if we sanitize the prefix by itself and we have overwrite turned off, it will become "Subject_extracted"
- the next keys in the section will be like "Subject_extracted_LoginID" which is not so nice because it could just have been "Subject_LoginID" since there is no collision with this
If you're ok with the logic I can add a comment to document this more clearly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few comments but overall looks solid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Hello, this is my windows eventlog processing pipeline:
Not sure if this helps or not.
|
|
||
The first section of the input is treated as a whole block and stored in the extracted map with the key `Description`. | ||
|
||
Sections following the Description are expected to contain key-value pairs in the format key:value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if they don't have key:value pairs? The "are expected" suggests that it may not happen this way.
Is this a "must"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should rephrase because it's not a must but the lines that don't have a key:value pair will be ignored (unless there was already a key:value pair in the section. In this case it's considered a multi line value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just adding the bit about what happens if a key:value pair isn't found will help clarify what happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's documented a bit below with "Lines in a section without a preceding valid entry (key-value pair) are ignored and discarded."
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
Co-authored-by: Clayton Cornell <[email protected]>
PR Description
The existing eventlogmessage stage has a few parsing flaws that cannot be addressed without breaking changes (see the issue linked).
This is why I decided to create a new stage "windowsevent" which covers the same functionality and has the same arguments as the existing eventlogmessage, except that it parses the message differently.
New parsing logic:
The
windowsevent
stage expects the message to be structured in sections that are split by empty lines.The first section of the input is treated as a whole block and stored in the extracted map with the key
Description
.Sections following the
Description
are expected to contain key-value pairs in the format key: value.If the first line of a section has no value (e.g., "Subject:"), the key will act as a prefix for subsequent keys in the same section.
If a line within a section does not include the
:
symbol, it is considered part of the previous entry's value. The line is appended to the previous value, separated by a comma.Lines in a section without a preceding valid entry (key-value pair) are ignored and discarded.
I scrolled through Windows events on my personal computer to get some examples. You can check the example in the doc and in the tests to see the results.
Which issue(s) this PR fixes
Fixes #2337
Notes to the Reviewer
PR Checklist