add alerta service

This commit is contained in:
Alvin Pergens 2022-01-26 15:54:17 +01:00
parent ab61acab63
commit 63ddfcaf88
32 changed files with 118 additions and 3 deletions

View file

@ -0,0 +1,64 @@
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class Alerta extends NotificationProvider {
name = "alerta";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
let alertaUrl = `${notification.alertaapiEndpoint}/alert`;
let config = {
headers: {
"Content-Type": "application/json",
"Authorization": "Key " + notification.alertaapiKey,
"Accept": "text/json"
}
};
let data = {
environment: notification.alertaenvironment,
severity: notification.alertaalertState, // critical
status: notification.alertarecoverState, // cleared
correlate: [],
service: [ "UptimeKuma" ],
group: "UptimeKuma-" + monitorJSON["type"], // Type de Sonde
value: "Timeout",
tags: [ "uptimekuma" ],
attributes: {},
origin: "uptimekuma",
type: "browserAlert",
resource: monitorJSON["name"]
};
if (heartbeatJSON == null) {
let testdata = Object.assign( {
event: "TestAlert",
text: "Testing Successful.",
}, data );
await axios.post(alertaUrl, testdata)
} else if (heartbeatJSON["status"] == DOWN) {
let downdata = Object.assign( {
event: monitorJSON["name"],
value: "DOWN",
text: "[🔴 Down] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
}, data );
await axios.post(alertaUrl, downdata)
} else if (heartbeatJSON["status"] == UP) {
let updata = Object.assign( {
event: monitorJSON["name"],
value: "UP",
text: "[✅ Up] " + heartbeatJSON["msg"] + "\nTime (UTC): " + heartbeatJSON["time"],
}, data );
await axios.post(alertaUrl, updata)
}
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error)
}
}
}
module.exports = Alerta;

View file

@ -27,6 +27,7 @@ const SerwerSMS = require("./notification-providers/serwersms");
const Stackfield = require("./notification-providers/stackfield");
const WeCom = require("./notification-providers/wecom");
const GoogleChat = require("./notification-providers/google-chat");
const Alerta = require("./notification-providers/alerta");
class Notification {
@ -65,7 +66,8 @@ class Notification {
new SerwerSMS(),
new Stackfield(),
new WeCom(),
new GoogleChat()
new GoogleChat(),
new Alerta()
];
for (let item of list) {

View file

@ -0,0 +1,14 @@
<template>
<div class="mb-3">
<label for="alerta-api-endpoint" class="form-label">{{ $t("apiEndpoint") }}</label>
<input id="alerta-api-endpoint" v-model="$parent.notification.alertaapiEndpoint" type="text" class="form-control" required>
<label for="alerta-environment" class="form-label">{{ $t("environment") }}</label>
<input id="alerta-environment" v-model="$parent.notification.alertaenvironment" type="text" class="form-control" required>
<label for="alerta-api-key" class="form-label">{{ $t("apiKey") }}</label>
<input id="alerta-api-key" v-model="$parent.notification.alertaapiKey" type="text" class="form-control" required>
<label for="alerta-alert-state" class="form-label">{{ $t("alertState") }}</label>
<input id="alerta-alert-state" v-model="$parent.notification.alertaalertState" type="text" class="form-control" required>
<label for="alerta-recover-state" class="form-label">{{ $t("recoverState") }}</label>
<input id="alerta-recover-state" v-model="$parent.notification.alertarecoverState" type="text" class="form-control" required>
</div>
</template>

View file

@ -26,6 +26,7 @@ import SerwerSMS from "./SerwerSMS.vue";
import Stackfield from './Stackfield.vue';
import WeCom from "./WeCom.vue";
import GoogleChat from "./GoogleChat.vue";
import Alerta from "./Alerta.vue";
/**
* Manage all notification form.
@ -60,7 +61,8 @@ const NotificationFormList = {
"serwersms": SerwerSMS,
"stackfield": Stackfield,
"WeCom": WeCom,
"GoogleChat": GoogleChat
"GoogleChat": GoogleChat,
"alerta": Alerta
};
export default NotificationFormList;

View file

@ -360,4 +360,5 @@ export default {
smtpDkimHashAlgo: "Хеш алгоритъм (по желание)",
smtpDkimheaderFieldNames: "Хедър ключове за подписване (по желание)",
smtpDkimskipFields: "Хедър ключове, които да не се подписват (по желание)",
alerta: "Alerta",
};

View file

@ -352,4 +352,5 @@ export default {
serwersmsPhoneNumber: "Telefonnummer",
serwersmsSenderName: "SMS Afsender Navn (registreret via kundeportal)",
stackfield: "Stackfield",
alerta: "Alerta",
};

View file

@ -350,4 +350,5 @@ export default {
serwersmsPhoneNumber: "Telefonnummer",
serwersmsSenderName: "Name des SMS-Absenders (über Kundenportal registriert)",
"stackfield": "Stackfield",
alerta: "Alerta",
};

View file

@ -361,4 +361,10 @@ export default {
smtpDkimHashAlgo: "Hash Algorithm (Optional)",
smtpDkimheaderFieldNames: "Header Keys to sign (Optional)",
smtpDkimskipFields: "Header Keys not to sign (Optional)",
alerta: "Alerta",
apiEndpoint: "API Endpoint",
environment: "Environment",
apiKey: "API Key",
alertState: "Alert State",
recoverState: "Recover State",
};

View file

@ -203,4 +203,5 @@ export default {
records: "registros",
"One record": "Un registro",
steamApiKeyDescription: "Para monitorear un servidor de juegos de Steam, necesita una clave Steam Web-API. Puede registrar su clave API aquí: ",
alerta: "Alerta",
};

View file

@ -197,4 +197,5 @@ export default {
pushbullet: "Pushbullet",
line: "LINE",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -202,4 +202,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -304,4 +304,5 @@ export default {
steamApiKeyDescription: "Pour surveiller un serveur Steam, vous avez besoin d'une clé Steam Web-API. Vous pouvez enregistrer votre clé ici : ",
"Current User": "Utilisateur actuel",
recent: "Récent",
alerta: "Alerta",
};

View file

@ -347,4 +347,5 @@ export default {
Cancel: "Otkaži",
"Powered by": "Pokreće",
Saved: "Spremljeno",
alerta: "Alerta",
};

View file

@ -350,4 +350,5 @@ export default {
serwersmsAPIPassword: "API jelszó",
serwersmsPhoneNumber: "Telefonszám",
serwersmsSenderName: "SMS feladó neve (regisztrált név az oldalon)",
alerta: "Alerta",
};

View file

@ -280,4 +280,5 @@ export default {
promosmsPhoneNumber: "Nomor telepon (untuk penerima Polandia Anda dapat melewati kode area)",
promosmsSMSSender: "Nama Pengirim SMS : Nama pra-registrasi atau salah satu bawaan: InfoSMS, Info SMS, MaxSMS, INFO, SMS",
"Feishu WebHookUrl": "Feishu WebHookUrl",
alerta: "Alerta",
};

View file

@ -361,4 +361,5 @@ export default {
smtpDkimheaderFieldNames: "Campi Intestazione da firmare (opzionale)",
smtpDkimskipFields: "Campi Intestazione da non firmare (opzionale)",
GoogleChat: "Google Chat (solo per Google Workspace)",
alerta: "Alerta",
};

View file

@ -198,4 +198,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -351,4 +351,5 @@ export default {
serwersmsPhoneNumber: "휴대전화 번호",
serwersmsSenderName: "보내는 사람 이름 (registered via customer portal)",
stackfield: "Stackfield",
alerta: "Alerta",
};

View file

@ -279,4 +279,5 @@ export default {
promosmsTypeSpeed: "SMS SPEED - Highest priority in system. Very quick and reliable but costly (about twice of SMS FULL price).",
promosmsPhoneNumber: "Phone number (for Polish recipient You can skip area codes)",
promosmsSMSSender: "SMS Sender Name : Pre-registred name or one of defaults: InfoSMS, SMS Info, MaxSMS, INFO, SMS",
alerta: "Alerta",
};

View file

@ -204,4 +204,5 @@ export default {
PushUrl: "Push URL",
HeadersInvalidFormat: "The request headers is geen geldige JSON: ",
BodyInvalidFormat: "De request body is geen geldige JSON: ",
alerta: "Alerta",
};

View file

@ -361,4 +361,5 @@ export default {
smtpDkimHashAlgo: "Algorytm Hashowania (Opcjonalne)",
smtpDkimheaderFieldNames: "Klucze nagłówka do podpisu (Opcjonalne)",
smtpDkimskipFields: "Klucze nagłówka do pominięcia (Opcjonalne)",
alerta: "Alerta",
};

View file

@ -197,4 +197,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -317,4 +317,5 @@ export default {
"Cancel": "Отмена",
"Created:": "Создано:",
"Show Tags": "Показать тэги",
alerta: "Alerta",
};

View file

@ -352,4 +352,5 @@ export default {
serwersmsPhoneNumber: "Telefonska številka",
serwersmsSenderName: "Ime SMS pošiljatelja (registrirani prek portala za stranke)",
"stackfield": "Stackfield",
};
alerta: "Alerta",
};

View file

@ -198,4 +198,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -198,4 +198,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -198,4 +198,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -197,4 +197,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -307,4 +307,5 @@ export default {
steamApiKeyDescription: "Để monitor các Steam Game Server bạn cần một Steam Web-API key. Bạn có thể đăng ký API key tại đây: ",
"Current User": "User hiện tại",
recent: "Gần đây",
alerta: "Alerta",
};

View file

@ -291,4 +291,5 @@ export default {
"Internal Room Id": "Internal Room Id",
matrixDesc1: "你可以在 Matrix 客户端房间设置的高级选项找到 Internal Room Id。格式类似于 !QMdRCpUIfLwsfjxye6:home.server。",
matrixDesc2: "请不要使用你自己的 Access Token这将开放你所有的账户权限和你加入的房间权限。你可以创建一个新的用户并邀请它至你允许的的房间中。你可以运行以下命令来获取 Access Token{0}",
alerta: "Alerta",
};

View file

@ -198,4 +198,5 @@ export default {
pushbullet: "Pushbullet",
line: "Line Messenger",
mattermost: "Mattermost",
alerta: "Alerta",
};

View file

@ -353,4 +353,5 @@ export default {
serwersmsPhoneNumber: "電話號碼",
serwersmsSenderName: "SMS 寄件人名稱 (由客戶入口網站註冊)",
"stackfield": "Stackfield",
alerta: "Alerta",
};