feat: critical alerts by modules - 2 #264
Merged
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.
Make several changes in the current critical alerts engine.
Now critical alerts are sent for each module individually.
Change the architecture of critical alert classes. Now these classes have
moduleIndex
field that allows them to detect for which module this critical alert should be triggered.To optimize calculation complexity, raw data that are needed for critical alerts to calculate their state is now extracted from the critical alert instance methods to the higher level. Now these raw data are fetched in the
CriticalAlerts
service and are passed to the critical alert instances in constructors on creation time. Also, these data are filtered by a specific module and epoch to reduce the size of containers that critical alert instances should look over.Introduce two new env variables
CRITICAL_ALERTS_MIN_ACTIVE_VAL_COUNT
andCRITICAL_ALERTS_MIN_AFFECTED_VAL_COUNT
that allow users to define custom numbers for the count of active and affected validators for the particular module for which a critical alert should be triggered. Define priority rules for these values. Add support for the new affected validators mechanics to critical alerts. Describe new priority rules in README.Now it is possible to set a share of active validators and a minimal threshold number for which a critical alert should be triggered in the new
CRITICAL_ALERTS_MIN_ACTIVE_VAL_COUNT
env variable. Previously these values were hard coded in the code and non-configurable.Add a new
nos_module_id
label to all critical alerts. So now it is possible to route alerts depending on the module to different channels via Alertmanager.Rules for sending critical alerts were slightly loosened. Previously alerts were sent when the number of affected validators was greater than the particular threshold. Now alerts are sent when the number of affected validators is greater or equal to the threshold.
Add information about the module to the alert summary.
Slightly change log info for critical alerts. Now logs display the critical alert name for every sent alert.
Calculate and store fetched module indexes in the Registry service and all dependent registry services (
LidoSource
,FileSource
,KeysapiSource
). This allows theCriticalAlerts
service to fetch all available module indexes conveniently.Fix a bug in the
isValid
module function of theFileSource
service. This function considered key files with multiple modules as invalid. Now this function can correctly validate key files with multiple modules.Update the
custom_mainnet.yaml
andcustom_testnet.yaml
templates to demonstrate how multiple modules can be defined in a file with keys.