Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Fix missing Windows events by changing getRecords(). #333
Fix missing Windows events by changing getRecords(). #333
Changes from 7 commits
f7a3486
e92166d
535225e
489f50c
3ece594
a3df775
b08b962
cae97ee
ef98274
3ac0fa4
74eb9b6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This code to track
recordNumber
is unnecessary it only used once and it already gets set before use.It gets parsed below and set in the
LogEvent
struct.I moved printing the error inside the
read()
function.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.
But what if
l.read()
happens to return NO valid records. Then we would never setrecordNumber
below and would get stuck on the bad record.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.
Let me know if I am crazy, but in the current
master
branch there is only 1 place where therecordNumber
variable is used:https://github.com/aws/amazon-cloudwatch-agent/blob/master/plugins/inputs/windows_event_log/wineventlog/wineventlog.go#L136
And just before it is used it is set:
https://github.com/aws/amazon-cloudwatch-agent/blob/master/plugins/inputs/windows_event_log/wineventlog/wineventlog.go#L131
There is no point in setting a local variable or incrementing it if it is not used.
I was confused by this code too :)
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.
EvtNext()
is a stateful call, meaning each call will return a different list of EvtHandles, or nothing.Since the
windowsEventLog.read()
method callsEvtNext()
it is also stateful.MSDN:
https://docs.microsoft.com/en-us/windows/win32/wes/querying-for-events#reading-events-from-the-result-set
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.
Ah I see. This almost seems like a bug then, if the following happened:
I guess that's an edge case though and would be resolved as soon as a new valid event is available in the log. (Although it could be fixed by sending
recordNumber
onl.offsetCh
.)