-
Notifications
You must be signed in to change notification settings - Fork 207
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 windows event logs to only starts once #851
Conversation
0a0ee6e
to
f019777
Compare
f019777
to
c074c04
Compare
@@ -25,6 +27,8 @@ const ( | |||
forcePullInterval = 250 * time.Millisecond | |||
) | |||
|
|||
var startOnlyOnce sync.Once |
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.
nit: I think we might be able to move this into the Plugin
struct since the plugin should only be initialized in the init
function and should be the same instance wherever it's used.
ec830c6
to
c09405e
Compare
c09405e
to
c9ffed8
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #851 +/- ##
==========================================
+ Coverage 57.58% 60.42% +2.83%
==========================================
Files 370 356 -14
Lines 17548 18116 +568
==========================================
+ Hits 10105 10946 +841
+ Misses 6848 6595 -253
+ Partials 595 575 -20
☔ View full report in Codecov by Sentry. |
Name: "System Event//Log::", | ||
} | ||
plugin.Events = append(plugin.Events, ec) | ||
require.Equal(t, 0, len(plugin.newEvents), "Start should be ran only once so there should be only 1 new event") |
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.
nit: The error log would be misleading.
Please update the title to better reflect the change. Maybe something like "Fix windows event logs to only starts once" |
Description of the issue
Currently, when the agent start in windows both log agent and telegraf start the windows log event plugin. As a result, the the plugins generates duplicate logs.
Description of changes
Changed the start function of the plugin to be exclusively ran once to avoid any duplicate plugin calls to be started.
License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Created and ran a units test this can be seen in TestWindowsDuplicateStart
Also ran integration test: this is the instance where there is only logs
Requirements
Before commit the code, please do the following steps.
make fmt
andmake fmt-sh
make lint