2020-07-18 18:43:30 +02:00
# Send alerts with POST requests
BGPalerter can send alerts by means of POST requests to a provided URL.
This can be done by configuring the module reportHTTP. Read [here ](configuration.md#reporthttp ) to understand how.
For configuring reportHTTP, essentially you need to specify two things:
* The URL
* A template of the POST request.
If you are using [user groups ](usergroups.md ), you can specify a URL for every user group. This can be done inside `hooks` , a dictionary containing API URLs grouped by user group (key: group, value: URL).
The default user group is mandatory.
Example:
```yaml
hooks:
default: https://MY_WEB_HOOK/
noc: https://MY_WEB_HOOK_FOR_THE_NOC_GROUP
```
2020-12-01 02:43:55 +01:00
You can also specify a template for each type of alert (channel). More information about templates is available [here ](context.md ).
2020-07-18 18:43:30 +02:00
Example:
```yaml
isTemplateJSON: true
templates:
default: '{"message": "${summary}", "color": "blue"}'
visibility: '{"message": "${summary}", "color": "orange"}'
```
Templates are expressed as strings. If the parameter `isTemplateJSON` is set to true, the string will be converted to JSON before to be posted.
What follows is a list of examples showing how to adapt this module to some well-known applications.
## Mattermost
Mattermost is an open source messaging platform.
```yaml
reports:
- file: reportHTTP
channels:
- hijack
- newprefix
- visibility
- path
- misconfiguration
- rpki
params:
templates:
default: '{"attachments": [
2020-12-01 02:43:55 +01:00
{
"author_name" : "BGPalerter",
"fields": [
{"title": "Event type:", "value": "${type}", "short": "true"},
{"title": "First event:", "value": "${earliest} UTC", "short": "true"},
{"title": "Last event:", "value": "${latest} UTC", "short": "true"}
],
"text": "${channel}: ${summary}", "color": "#ffffff "
}
]}'
2020-07-18 18:43:30 +02:00
isTemplateJSON: true
headers:
showPaths: 0 # Amount of AS_PATHs to report in the alert
hooks:
default: WEBHOOK_URL
```
Thanks to [@fstolba ](https://github.com/nttgin/BGPalerter/issues/81 ).
## Pushover
Pushover is an app that makes it easy to get real-time notifications on your Android, iPhone, iPad, and Desktop.
```yaml
- file: reportHTTP
channels:
- hijack
- newprefix
- visibility
- path
- misconfiguration
- rpki
params:
templates:
default: '{"message": "${channel}: ${summary}", "title": "BGPalerter", "priority": "1", "token": "_YOUR_API_TOKEN_HERE_", "user": "_YOUR_USER_KEY_HERE_"}'
headers:
isTemplateJSON: true
showPaths: 0
hooks:
default: https://api.pushover.net/1/messages.json
```
Thanks to [Hugo Salgado ](https://twitter.com/huguei/status/1278771420525408258 ).
2020-12-01 10:59:57 +10:00
## MS Teams
2020-12-01 02:43:55 +01:00
Microsoft Teams is a communication platform developed by Microsoft, as part of the Microsoft 365 family of products.
2020-12-01 10:59:57 +10:00
```yaml
reports:
- file: reportHTTP
channels:
- hijack
- newprefix
- visibility
- path
- misconfiguration
- rpki
params:
templates:
default: '{
"@type ": "MessageCard",
"@context ": "http://schema.org/extensions",
"themeColor": "d76100",
2020-12-01 02:43:55 +01:00
"summary": "BGPalerter",
2020-12-01 10:59:57 +10:00
"sections": [{
2020-12-01 02:43:55 +01:00
"activityTitle": "BGPalerter",
"activitySubtitle": "${channel}",
2020-12-01 10:59:57 +10:00
"facts": [{
2020-12-01 02:43:55 +01:00
"name": "Summary",
"value": "${summary}"
2020-12-01 10:59:57 +10:00
}, {
2020-12-01 02:43:55 +01:00
"name": "Event type",
"value": "${type}"
2020-12-01 10:59:57 +10:00
}, {
2020-12-01 02:43:55 +01:00
"name": "First event",
"value": "${earliest} UTC"
2020-12-01 10:59:57 +10:00
}, {
2020-12-01 02:43:55 +01:00
"name": "Last event",
"value": "${latest} UTC"
2020-12-01 10:59:57 +10:00
}],
"markdown": true
}]
}'
isTemplateJSON: true
headers:
showPaths: 0 # Amount of AS_PATHs to report in the alert
hooks:
2020-12-01 02:43:55 +01:00
default: https://WEBHOOK_URL
2020-12-01 10:59:57 +10:00
```
2020-12-01 02:43:55 +01:00
Thanks [arpanet-creeper ](https://github.com/nttgin/BGPalerter/pull/412 ) for the help.