Skip to content

Commit dc62207

Browse files
Merge branch 'dev'
2 parents 34ce8dd + 8136252 commit dc62207

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4062
-2336
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Please uncomment the related section and configure according to your needs.
4343
- [Connectors](docs/configuration.md#connectors)
4444
- [Monitors](docs/configuration.md#monitors)
4545
- [Reports](docs/configuration.md#reports)
46+
- [reportFile](docs/configuration.md#reportfile)
47+
- [reportEmail](docs/configuration.md#reportemail)
48+
- [reportSlack](docs/configuration.md#reportslack)
49+
- [reportKafka](docs/configuration.md#reportkafka)
50+
- [Uptime monitor](docs/uptime-monitor.md)
4651
- [More information for developers](docs/develop.md)
4752
- [All npm commands](docs/develop.md#all-npm-commands)
4853

config.yml.example

+33-3
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,28 @@ monitors:
3838
params:
3939
thresholdMinPeers: 10
4040

41+
- file: MonitorAS
42+
channel: misconfiguration
43+
name: asn-monitor
44+
params:
45+
thresholdMinPeers: 2
46+
4147
reports:
4248
- file: reportFile
4349
channels:
4450
- hijack
4551
- newprefix
4652
- visibility
4753
- path
54+
- misconfiguration
4855

4956
# - file: reportEmail
5057
# channels:
5158
# - hijack
5259
# - newprefix
5360
# - visibility
5461
# - path
62+
# - misconfiguration
5563
# params:
5664
# showPaths: 5 # Amount of AS_PATHs to report in the alert
5765
# senderEmail: bgpalerter@xxxx
@@ -62,6 +70,7 @@ reports:
6270
# host: localhost
6371
# port: 25
6472
# secure: false # If true the connection will use TLS when connecting to server. If false it will be still possible doing connection upgrade via STARTTLS
73+
# ignoreTLS: false # If true TLS will be completely disabled, including STARTTLS. Set this to true if you see certificate errors in the logs.
6574
# auth:
6675
# user: username
6776
# pass: password
@@ -72,13 +81,14 @@ reports:
7281
# default:
7382
7483
75-
#
84+
7685
# - file: reportSlack
7786
# channels:
7887
# - hijack
7988
# - newprefix
8089
# - visibility
8190
# - path
91+
# - misconfiguration
8292
# params:
8393
# colors:
8494
# hijack: '#d60b1c'
@@ -87,13 +97,14 @@ reports:
8797
# path: '#42cbf5'
8898
# hooks:
8999
# default: _YOUR_SLACK_WEBHOOK_URL_
90-
#
100+
91101
# - file: reportKafka
92102
# channels:
93103
# - hijack
94104
# - newprefix
95105
# - visibility
96106
# - path
107+
# - misconfiguration
97108
# params:
98109
# host: localhost:9092
99110
# topics:
@@ -128,4 +139,23 @@ logging:
128139
maxSize: 80m
129140
maxFiles: 14d
130141

131-
checkForUpdatesAtBoot: true
142+
checkForUpdatesAtBoot: true
143+
144+
145+
############################
146+
# Uptime monitor settings:
147+
# The uptime monitor enables an API (http://localhost:8011/status) which shows the current status of BGPalerter
148+
# If any component reports an invalid state, the "warning" field will be set to true and the HTTP status code will be 500.
149+
#
150+
# - active - A boolean that if set to true enables the monitor. When set to false none of the monitoring components
151+
# and dependencies are loaded (and no port has to be open).
152+
# - useStatusCodes - A boolean that if set to true enables HTTP status codes in the response. Nothing changes in the
153+
# JSON output provided by the API.
154+
# - port - The port on which the API will be reachable.
155+
156+
uptimeMonitor:
157+
active: false
158+
useStatusCodes: true
159+
port: 8011
160+
161+
############################

docs/configuration.md

+83-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ The following are common parameters which it is possible to specify in the confi
1616
|logging.zippedArchive| Indicates if when a file gets rotates it has to be zipped or not. | A boolean | true | Yes |
1717
|logging.maxSize| Indicates the maximum file size allowed before to be rotated (by adding .number ad the end). This allows to rotate files when logRotatePattern still the same but the file is too big | A string (indicating an amount and a unit of measure) | 20m | Yes |
1818
|logger.maxFiles| Indicates the maximum amount of files or the maximum amount of days the files are retained. When this threshold is passed, files get deleted. | A string (a number or an amount of days ending with "d") | 14d | Yes |
19-
|checkForUpdatesAtBoot| Indicates if at each booth the application should check for updates. If an update is available, a notification will be sent to the default group. If you restart the process often (e.g. debugging, experimenting etc.) set this to false to avoid notifications. Anyway, BGPalerter checks for updates every 10 days.| A boolean | true | Yes |
19+
|checkForUpdatesAtBoot| Indicates if at each booth the application should check for updates. If an update is available, a notification will be sent to the default group. If you restart the process often (e.g. debugging, experimenting etc.) set this to false to avoid notifications. Anyway, BGPalerter checks for updates every 10 days.| A boolean | true | Yes |
20+
|uptimeMonitor| A dictionary of parameters containing the configuration for the uptime monitor feature. The API showing the status of BGPalerter is available at The API is reachable at `http://localhost:8011/status`| | | No |
21+
|uptimeMonitor.active| A boolean that if set to true enables the monitor. When set to false none of the monitoring components and dependencies are loaded (and no port has to be open).| A boolean | true | No |
22+
|uptimeMonitor.useStatusCodes| A boolean that if set to true enables HTTP status codes in the response. Nothing changes in the JSON output provided by the API. | A boolean | true | No |
23+
|uptimeMonitor.port| The port on which the API will be reachable.| An integer | 8011 | No |
2024

2125

2226
## Composition
@@ -27,6 +31,11 @@ You can compose the tool with 3 main components: connectors, monitors, and repor
2731
* Monitors analyze the data flow and produce alerts. Different monitors try to detect different issues.
2832
* Reports send/store the alerts, e.g. by email or to a file.
2933

34+
> In config.yml.example there are all the possible components declarations (similar to the one of the example below). You can enable the various components by uncommenting the related block.
35+
36+
37+
Example of composition:
38+
3039
```yaml
3140
connectors:
3241
- file: connectorRIS
@@ -127,20 +136,92 @@ Parameters for this monitor module:
127136
|thresholdMinPeers| Minimum number of peers that need to see the BGP update before to trigger an alert. |
128137

129138

139+
#### monitorPath
140+
141+
This monitor detects BGP updates containing AS_PATH which match particular regular expressions.
142+
143+
> Example:
144+
> The prefixes list of BGPalerter has an entry such as:
145+
> ```yaml
146+
> 165.254.255.0/24:
147+
> asn: 15562
148+
> description: an example on path matching
149+
> ignoreMorespecifics: false
150+
> path:
151+
> match: ".*2194,1234$"
152+
> notMatch: ".*5054.*"
153+
> matchDescription: detected scrubbing center
154+
> ```
155+
> An alert will be generated when a BGP announcements for 165.254.255.0/24 or a more specific contains an AS_PATH
156+
> terminating in 2194,1234 but not containing 5054. The generated alert will report the matchDescription field.
157+
158+
More path matching options are available, see the entire list [here](prefixes.md#prefixes-fields)
159+
160+
Parameters for this monitor module:
161+
162+
|Parameter| Description|
163+
|---|---|
164+
|thresholdMinPeers| Minimum number of peers that need to see the BGP update before to trigger an alert. |
165+
166+
167+
168+
130169
#### monitorNewPrefix
131170

132-
This monitor has the logic to detect unexpected change of configuration in the form of new prefixes announced by the correct AS.
171+
This monitor has the logic to detect unexpected change of configuration in the form of new more specific prefixes announced by the correct AS.
172+
133173
In particular, it will monitor for all the declared prefixes and will trigger an alert when:
134174
* A sub-prefix of the monitored prefix starts to be announced by the same AS declared for the prefix.
135175

176+
> Example:
177+
> The prefixes list of BGPalerter has an entry such as:
178+
> ```yaml
179+
> 50.82.0.0/20:
180+
> asn: 58302
181+
> description: an example
182+
> ignoreMorespecifics: false
183+
> ```
184+
> If in config.yml monitorNewPrefix is enabled you will receive alerts every time a more specific prefix (e.g. 50.82.4.0/24) is announced by AS58302.
185+
136186
Parameters for this monitor module:
137187

138188
|Parameter| Description|
139189
|---|---|
140190
|thresholdMinPeers| Minimum number of peers that need to see the BGP update before to trigger an alert. |
141191

142192

193+
#### monitorAS
194+
195+
This monitor will listen for all announcements produced by the monitored Autonomous Systems and will detect when a prefix, which is not in the monitored prefixes list, is announced.
196+
This is useful if you want to be alerted in case your AS starts announcing something you didn't intend to announce (e.g. misconfiguration, typo).
197+
198+
199+
> Example:
200+
> The prefixes list of BGPalerter has an options.monitorASns list declared, such as:
201+
> ```yaml
202+
> 50.82.0.0/20:
203+
> asn: 58302
204+
> description: an example
205+
> ignoreMorespecifics: false
206+
>
207+
> options:
208+
> monitorASns:
209+
> 58302:
210+
> group: default
211+
> ```
212+
> If in config.yml monitorAS is enabled, you will receive alerts every time a prefix not already part of the prefixes list is announced by AS58302.
213+
>
214+
>If AS58302 starts announcing 45.230.23.0/24 an alert will be triggered. This happens because such prefix is not already monitored (it's not a sub prefix of 50.82.0.0/20).
215+
216+
You can generate the options block in the prefixes list automatically. Refer to the options `-s` and `-m` in the [auto genere prefixes documentation](prefixes.md#generate).
143217

218+
Parameters for this monitor module:
219+
220+
|Parameter| Description|
221+
|---|---|
222+
|thresholdMinPeers| Minimum number of peers that need to see the BGP update before to trigger an alert. |
223+
224+
144225
### Reports
145226

146227
Possible reports are:

docs/prefixes.md

+40-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ Below the list of possible parameters. **Remember to prepend them with a `--` in
1515
| Parameter | Description | Expected format | Example | Required |
1616
|---|---|---|---|---|
1717
| -o | The YAML output file | A string ending in ".yml" | prefixes.yml | Yes |
18-
| -a | The AS number(s) you want to generate the list for | A comma-separated list of integers | 2914,3333 | No (one among -a, -p, -pf is required) |
18+
| -a | The AS number(s) you want to generate the list for | A comma-separated list of integers | 2914,3333 | No (one among -a, -p, -l is required) |
1919
| -e | Prefixes to exclude from the list | A comma-separated list of prefixes | 165.254.255.0/24,192.147.168.0/24 | No |
2020
| -i | Avoid monitoring delegated prefixes. If a more specific prefix is found and it results announced by an AS different from the one declared in -a, then set `ignore: true` and `ignoreMorespecifics: true` | Nothing | | No
21-
| -p | Prefixes for which the list will be generated | A comma-separated list of prefixes | 165.254.255.0/24,192.147.168.0/24 | No (one among -a, -p, -pf is required) |
22-
| -pf | A file containing the prefixes for which the list will be generated | A text file having a prefix for each line | prefixes.txt | No (one among -a, -p, -pf is required) |
21+
| -p | Prefixes for which the list will be generated | A comma-separated list of prefixes | 165.254.255.0/24,192.147.168.0/24 | No (one among -a, -p, -l is required) |
22+
| -l | A file containing the prefixes for which the list will be generated | A text file having a prefix for each line | prefixes.txt | No (one among -a, -p, -l is required) |
23+
| -s | A list of ASns to be monitored. See [monitorASns](#monitorASns) for more information | A comma separated list of integer | 2914,3333 | No |
24+
| -m | Monitor all ASns which are origin of at least one of the monitored prefixes. This option is the same of `-s` except that the list of ASns is automatically generated by detecting the origin AS of all the monitored prefixes. See [monitorASns](#monitorASns) for more information | Nothing | | No |
2325

2426

2527
## <a name="prefixes-fields"></a>Prefixes list fields
@@ -43,7 +45,6 @@ The prefix list is a file containing a series of blocks like the one below, one
4345
matchDescription: detected scrubbing center
4446
maxLength: 128
4547
minLength: 2
46-
4748
```
4849

4950
###### <a name="array"></a>
@@ -73,6 +74,40 @@ Below the complete list of attributes (the dot notation is used to represent yml
7374
| group | The name of the group that will receive alerts about this monitored prefix. By default all alerts are sent to the "default" group. | A string | No |
7475

7576

77+
### Options entry
78+
79+
Optionally the prefixes list can contain an `options` entry, such us:
80+
81+
```yaml
82+
options:
83+
monitorASns:
84+
2914:
85+
group: default
86+
```
87+
88+
The `options` entry allows the configuration of additional monitoring options directly from the prefixes list file.
89+
90+
| Option | Description |
91+
|---|---|
92+
| monitorASns | A dictionary of ASns to be monitored. Each entry of the dictionary has the ASn as key. Each value of the dictionary contains the monitoring settings.|
93+
94+
#### monitorASns
95+
96+
Allows for generic monitoring (not related to specific prefixes) of Autonomous Systems.
97+
98+
An example of monitorASns configuration is:
99+
100+
```yaml
101+
monitorASns:
102+
2914:
103+
group: ntt
104+
3333:
105+
group: ripencc
106+
```
107+
108+
The AS2914 and AS3333 will be monitored. The alerts related to AS2914 will be sent to the "ntt" user group and the alerts for AS3333 to the "ripencc" user group.
109+
110+
The monitor in charge of doing this type of detection is [monitorAS (click for more information)](configuration.md#monitoras).
76111

77112
### Optimized regular expressions for AS path matching
78113

@@ -82,6 +117,6 @@ To drastically optimize the process, try to use one of the following regular exp
82117

83118
* "789$" - match paths that originate with AS789
84119
* "456" - match any path that traverses AS456 at any point
85-
* "^123,456" - match paths where the last traversed ASNs were 123 and 456 (in that order)
120+
* "^123,456" - match paths where the last traversed ASns were 123 and 456 (in that order)
86121
* "^123,456,789$" - match the exact path [123, 457, 789]
87122
* "[789,101112]" - match paths containing the AS_SET {789, 101112}

docs/uptime-monitor.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Uptime Monitor
2+
3+
The Uptime Monitor is a feature that allows to monitor the status of BGPalerter.
4+
The API is reachable at `http://localhost:8011/status`.
5+
The API, in addition to the JSON answer, can use HTTP status codes for an easier integration with Nagios and similar.
6+
7+
When this feature is disabled, no extra dependencies are loaded and no open port is required.
8+
Please, see [configuration](configuration.md) for all the possible configuration parameters.
9+
10+
The following is an example of the API output.
11+
12+
```
13+
{
14+
"warning": false,
15+
"connectors": [
16+
{
17+
"name": "ConnectorRIS",
18+
"connected": true
19+
}
20+
]
21+
}
22+
```

0 commit comments

Comments
 (0)