mirror of
https://github.com/nttgin/BGPalerter.git
synced 2024-05-19 06:50:08 +00:00
introduced alertOnlyOnce configuration parameter
This commit is contained in:
@@ -99,7 +99,21 @@ reports:
|
|||||||
# default: bgpalerter
|
# default: bgpalerter
|
||||||
|
|
||||||
|
|
||||||
notificationIntervalSeconds: 7200 # Repeat the same alert (which keeps being triggered) after x seconds
|
############################
|
||||||
|
# Notification settings:
|
||||||
|
# - notificationIntervalSeconds
|
||||||
|
# Defines the amount of seconds after which an alert can be repeated. An alert is repeated only if the event that
|
||||||
|
# triggered it is not yet solved. Please, don't set this value to Infinity, use instead alertOnlyOnce.
|
||||||
|
#
|
||||||
|
# - alertOnlyOnce - A boolean that, if set to true, will prevent repetitions of the same alert even if the event that
|
||||||
|
# triggered it is not yet solved. In this case notificationIntervalSeconds will be ignored.
|
||||||
|
# If set to true, the signature of all alerts will be cached in order to recognize if they already happened in
|
||||||
|
# the past. This may lead to a memory leak if the amount of alerts is considerable.
|
||||||
|
|
||||||
|
notificationIntervalSeconds: 7200
|
||||||
|
alertOnlyOnce: false
|
||||||
|
|
||||||
|
############################
|
||||||
|
|
||||||
# Below the files containing the monitored prefixes. Please see prefixes.yml for an example.
|
# Below the files containing the monitored prefixes. Please see prefixes.yml for an example.
|
||||||
# This is an array (use new lines and dashes!)
|
# This is an array (use new lines and dashes!)
|
||||||
|
@@ -7,9 +7,8 @@ The following are common parameters which it is possible to specify in the confi
|
|||||||
| Parameter | Description | Expected format | Example | Required |
|
| Parameter | Description | Expected format | Example | Required |
|
||||||
|---|---|---|---|---|
|
|---|---|---|---|---|
|
||||||
|environment| You can specify various environments. The values "production" (not verbose) and "development" (verbose) will affect the verbosity of the error/debug logs. Other values don't affect the functionalities, they will be used to identify from which environment the log is coming from. | A string | production | Yes |
|
|environment| You can specify various environments. The values "production" (not verbose) and "development" (verbose) will affect the verbosity of the error/debug logs. Other values don't affect the functionalities, they will be used to identify from which environment the log is coming from. | A string | production | Yes |
|
||||||
|notificationIntervalSeconds| The amount of seconds before the same alert can be repeated. An alert is repeated only if the cause of it has not being solved. | An integer | 1800 | Yes |
|
|notificationIntervalSeconds|Defines the amount of seconds after which an alert can be repeated. An alert is repeated only if the event that triggered it is not yet solved. Please, don't set this value to Infinity, use instead alertOnlyOnce. | An integer | 1800 | Yes |
|
||||||
|clearNotificationQueueAfterSeconds| If the cause of an alert is resolved, then stop waiting for more information about the issue. | An integer (greater than notificationIntervalSeconds) | 1900 | Yes |
|
|alertOnlyOnce| A boolean that, if set to true, will prevent repetitions of the same alert even if the event that triggered it is not yet solved. In this case notificationIntervalSeconds will be ignored. If set to true, the signature of all alerts will be cached in order to recognize if they already happened in the past. This may lead to a memory leak if the amount of alerts is considerable. | A boolean | false | No |
|
||||||
|checkStaleNotificationsSeconds| The amount of seconds between a check on stale alerts. A stale alert happens when the cause of an alert is resolved before the next notification round, in such a case send it anyway. | An integer | 60 | Yes |
|
|
||||||
|monitoredPrefixesFiles| The [list](docs/prefixes.md#array) of files containing the prefixes to monitor. See [here](docs/prefixes.md#prefixes) for more informations. | A list of strings (valid .yml files) | -prefixes.yml | Yes |
|
|monitoredPrefixesFiles| The [list](docs/prefixes.md#array) of files containing the prefixes to monitor. See [here](docs/prefixes.md#prefixes) for more informations. | A list of strings (valid .yml files) | -prefixes.yml | Yes |
|
||||||
|logging| A dictionary of parameters containing the configuration for the file logging. | || Yes|
|
|logging| A dictionary of parameters containing the configuration for the file logging. | || Yes|
|
||||||
|logging.directory| The directory where the log files will be generated. The directory will be created if not existent. | A string | logs | Yes |
|
|logging.directory| The directory where the log files will be generated. The directory will be created if not existent. | A string | logs | Yes |
|
||||||
|
1
env.js
1
env.js
@@ -107,6 +107,7 @@ let config = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
notificationIntervalSeconds: 7200,
|
notificationIntervalSeconds: 7200,
|
||||||
|
alarmOnlyOnce: false,
|
||||||
monitoredPrefixesFiles: ["prefixes.yml"],
|
monitoredPrefixesFiles: ["prefixes.yml"],
|
||||||
logging: {
|
logging: {
|
||||||
directory: "logs",
|
directory: "logs",
|
||||||
|
@@ -134,8 +134,9 @@ export default class Monitor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_clean = (group) => {
|
_clean = (group) => {
|
||||||
|
if (this.config.alertOnlyOnce) {
|
||||||
if (new Date().getTime() > group.latest + (this.internalConfig.clearNotificationQueueAfterSeconds * 1000)) {
|
delete this.alerts[group.id];
|
||||||
|
} else if (this.config.alertOnlyOnce && new Date().getTime() > group.latest + (this.internalConfig.clearNotificationQueueAfterSeconds * 1000)) {
|
||||||
delete this.alerts[group.id];
|
delete this.alerts[group.id];
|
||||||
delete this.sent[group.id];
|
delete this.sent[group.id];
|
||||||
|
|
||||||
@@ -148,7 +149,9 @@ export default class Monitor {
|
|||||||
_checkLastSent = (group) => {
|
_checkLastSent = (group) => {
|
||||||
const lastTimeSent = this.sent[group.id];
|
const lastTimeSent = this.sent[group.id];
|
||||||
|
|
||||||
if (lastTimeSent) {
|
if (lastTimeSent && this.config.alertOnlyOnce) {
|
||||||
|
return false;
|
||||||
|
} else if (lastTimeSent) {
|
||||||
|
|
||||||
const isThereSomethingNew = lastTimeSent < group.latest;
|
const isThereSomethingNew = lastTimeSent < group.latest;
|
||||||
const isItTimeToSend = new Date().getTime() > lastTimeSent + (this.internalConfig.notificationIntervalSeconds * 1000);
|
const isItTimeToSend = new Date().getTime() > lastTimeSent + (this.internalConfig.notificationIntervalSeconds * 1000);
|
||||||
|
Reference in New Issue
Block a user