1
0
mirror of https://github.com/nttgin/BGPalerter.git synced 2024-05-19 06:50:08 +00:00

added color to reportSlack

This commit is contained in:
Massimo Candela
2019-09-18 11:41:27 +02:00
parent caaf849075
commit dbd4a0b5f8
2 changed files with 100 additions and 91 deletions

View File

@@ -1,87 +1,91 @@
environment: production
connectors:
- file: connectorRIS
name: ris
params:
carefulSubscription: true
url: wss://ris-live.ripe.net/v1/ws/
subscription:
moreSpecific: true
type: UPDATE
host:
socketOptions:
includeRaw: false
monitors:
- file: monitorHijack
channel: hijack
name: basic-hijack-detection
- file: monitorNewPrefix
channel: newprefix
name: prefix-detection
- file: monitorVisibility
channel: visibility
name: withdrawal-detection
params:
threshold: 10
reports:
- file: reportFile
channels:
- hijack
- newprefix
- visibility
# - file: reportEmail
# channels:
# - hijack
# - newprefix
# - visibility
# params:
# senderEmail: bgpalerter@xxxx
# # BGPalerter uses nodemailer.
# # The smtp section can be configured with all the parameters available at https://nodemailer.com/smtp/
# # the following are just the most useful one
# smtp:
# host: localhost
# port: 25
# 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
# auth:
# user: username
# pass: password
# type: login
# tls:
# rejectUnauthorized: true # Reject unauthorized certificates
# notifiedEmails:
# default:
# - joe@example.org
# - noc@example.org
#
# - file: reportSlack
# channels:
# - hijack
# - newprefix
# - visibility
# params:
# hooks:
# default: _YOUR_SLACK_WEBHOOK_URL_
checkStaleNotificationsSeconds: 60
notificationIntervalSeconds: 1800 # Repeat the same alert (which keeps being triggered) after x seconds
clearNotificationQueueAfterSeconds: 1900 # Stop with the alert for an event which didn't happen again in x seconds
# The file containing the monitored prefixes. Please see prefixes.yml for an example
# This is an array (use new lines and dashes!)
monitoredPrefixesFiles:
- prefixes.yml
logging:
directory: logs
logRotatePattern: YYYY-MM-DD # Whenever the pattern changes, a new file is created and the old one rotated
zippedArchive: true
maxSize: 20m
maxFiles: 14d
environment: production
connectors:
- file: connectorRIS
name: ris
params:
carefulSubscription: true
url: wss://ris-live.ripe.net/v1/ws/
subscription:
moreSpecific: true
type: UPDATE
host:
socketOptions:
includeRaw: false
monitors:
- file: monitorHijack
channel: hijack
name: basic-hijack-detection
- file: monitorNewPrefix
channel: newprefix
name: prefix-detection
- file: monitorVisibility
channel: visibility
name: withdrawal-detection
params:
threshold: 10
reports:
- file: reportFile
channels:
- hijack
- newprefix
- visibility
# - file: reportEmail
# channels:
# - hijack
# - newprefix
# - visibility
# params:
# senderEmail: bgpalerter@xxxx
# # BGPalerter uses nodemailer.
# # The smtp section can be configured with all the parameters available at https://nodemailer.com/smtp/
# # the following are just the most useful one
# smtp:
# host: localhost
# port: 25
# 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
# auth:
# user: username
# pass: password
# type: login
# tls:
# rejectUnauthorized: true # Reject unauthorized certificates
# notifiedEmails:
# default:
# - joe@example.org
# - noc@example.org
#
# - file: reportSlack
# channels:
# - hijack
# - newprefix
# - visibility
# params:
# colors:
# hijack: #d60b1c
# newprefix: #fa9548
# visibility: #fad648
# hooks:
# default: _YOUR_SLACK_WEBHOOK_URL_
checkStaleNotificationsSeconds: 60
notificationIntervalSeconds: 1800 # Repeat the same alert (which keeps being triggered) after x seconds
clearNotificationQueueAfterSeconds: 1900 # Stop with the alert for an event which didn't happen again in x seconds
# The file containing the monitored prefixes. Please see prefixes.yml for an example
# This is an array (use new lines and dashes!)
monitoredPrefixesFiles:
- prefixes.yml
logging:
directory: logs
logRotatePattern: YYYY-MM-DD # Whenever the pattern changes, a new file is created and the old one rotated
zippedArchive: true
maxSize: 20m
maxFiles: 14d

View File

@@ -50,14 +50,19 @@ export default class ReportSlack extends Report {
}
_sendSlackMessage = (url, content) => {
console.log("sending to", url);
_sendSlackMessage = (url, message, content) => {
axios({
url: url,
method: "POST",
resposnseType: "json",
data: {
text: content.message
text: content.message,
attachments: [
{
color: this.params.colors[message],
title: message
}
]
}
})
.catch((error) => {
@@ -74,7 +79,7 @@ export default class ReportSlack extends Report {
for (let group of groups) {
if (this.params.hooks[group]) {
this._sendSlackMessage(this.params.hooks[group], content);
this._sendSlackMessage(this.params.hooks[group], message, content);
}
}
}