forked from badtuxx/giropops-monitoring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
incoming-webhook.js
54 lines (41 loc) · 1.33 KB
/
incoming-webhook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
class Script {
process_incoming_request({
request
}) {
var alertColor = "warning";
if (request.content.status == "resolved") {
alertColor = "good";
} else if (request.content.status == "firing") {
alertColor = "danger";
}
console.log(request.content);
let finFields = [];
for (i = 0; i < request.content.alerts.length; i++) {
var endVal = request.content.alerts[i];
var elem = {
title: "alertname: " + endVal.labels.alertname,
value: "*instance:* " + endVal.labels.instance,
short: false
};
finFields.push(elem);
finFields.push({title: "description", value: endVal.annotations.description});
finFields.push({title: "summary", value: endVal.annotations.summary});
}
return {
content: {
username: "Prometheus Alert",
attachments: [{
color: alertColor,
title_link: request.content.externalURL,
title: "Prometheus notification",
fields: finFields,
}]
}
};
return {
error: {
success: false
}
};
}
}