-
Notifications
You must be signed in to change notification settings - Fork 11
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
Filters able to raise alerts themselves #135
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FileManager: - only accepts const strings as no modification should occur. AlertManager: - Added WriteLogs, write the given string to the parameter log file. The input is considered as a log line, add new line at the end (\n). - Added REDISAddLogs, add given string to given redis list and publish it to given redis channel. If either the first or the other is not given, only apply to the given one. TODO: - implement in the filters - automated testing - flogs removal - Vulture integration (non-blocking)
Rewrote parts of the FileManager to be mor C++ friendly. Exceptions should not be used as error return / flags! Add operator bool to verify current state of the file the extensive way.
Core: AlertManager is now fully usable. The Core method for loading the associated configuration are imlemented. The new configuration fields are: - 'log_file_path': path to the log file dedicated to alerts - 'redis_socket_path': path to the redis UNIX socket to send alert to - 'alert_redis_list_name': name of the alert list in redis - 'alert_redis_channel_name': name of redis channel to publish alert to If the alert configuration is missing or wrong, it is not applied. If the alert configuration is partialy correct, apply as much as possible. In both cases a warning is logged. DARWIN_RAISE_ALERT(str) macro makes filter code easier to read. (AlertManager.hpp) CMake: Added the redis dependencie to the CMakeLists.txt because it will soon be part of all the filters through the Alert Manager. Added the required toolkit parts to the core sources. Added DARWIN_LIBRARIES var to remove duplicata and avoid core libraries mistake. fhostlookup: Migration to the Alert Manager done and hand tested.
NOT TESTED! All the filters are migrated to use the AlertManager. All the filters compile on linux.
Upadted configurations exaple to match the new alerting workflow. Added missing DARWIN_RAISE_ALERT to fdga.
Added ftest to enable easier testing of the core functions. This filter is not compiled by default but is mandatory for tests.
Tests are generated to cover all the possible cases. TODO: Run the tests.
Fix log in ftanomaly tests. Fix TEST search in CMakeList. TEST being a cmake function the word needs quotes around. Removed useless files. Fix multiple errors in AlertManager testing. Added missing certitude pushback in TestTask. Removed duplicate alert in file in ftanomaly. Replaced some double quotes by simple quotes in order to respect the json format of the logs.
As the log rotate mechanism was put to my attention, this will require a dev and associated tests. |
Now the alert file rotation is handled by the SIGHUP or SIGUSR1 signal. Added AlertManager file rotation automated test. Force reopen is now possible with our FiLeManager. File opening / reopening is now done under mutex lock to prevent writing while opening / closing the file.
frikilax
requested changes
Dec 11, 2019
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Co-Authored-By: frikilax <[email protected]>
Added a slight delay (1 millisecond) before retrying to write the alert.
frikilax
approved these changes
Dec 11, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
✨ Pull Request Template
📃 Type of change
Breaking change: fix or feature that would cause existing functionality to not work as expected.
💡 Related Issue(s)
✒️ Description
BREAKING: The filters no longer launch alert on 101 code (error code).
CAUTION: This PR implies new configuration fields for the filters. However those are not mandatory (see filters documentation).
Adding an AlertManager to the Core to enable every filter to raise an alert.
The alerts can be raised in :
Alert file rotation is handled catching the SIGHUP or SIGUSR1 signal.
Core
The new alerting configuration fields are:
If the alert configuration is missing or wrong, it is not applied.
If the alert configuration is partialy correct, apply as much as possible.
In both cases a warning is logged.
DARWIN_RAISE_ALERT(str) macro makes filter code easier to read. (AlertManager.hpp)
CMake
FileManager
Filters
Tests
🎯 Test Environments
FreeBSD (version)
Ubuntu (version)
✔️ Checklist: