|
|
@ -19,7 +19,11 @@ export class Alert { |
|
|
|
|
|
|
|
|
|
|
|
protected async send(segment) { |
|
|
|
protected async send(segment) { |
|
|
|
const notification = await this.makeNotification(segment); |
|
|
|
const notification = await this.makeNotification(segment); |
|
|
|
sendNotification(notification); |
|
|
|
try { |
|
|
|
|
|
|
|
await sendNotification(notification); |
|
|
|
|
|
|
|
} catch(error) { |
|
|
|
|
|
|
|
console.error(`can't send notification ${error}`); |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected async makeNotification(segment: Segment): Promise<Notification> { |
|
|
|
protected async makeNotification(segment: Segment): Promise<Notification> { |
|
|
@ -187,7 +191,7 @@ export class AlertService { |
|
|
|
this._alerts[id].receive(segment); |
|
|
|
this._alerts[id].receive(segment); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public sendMsg(message: string, type: WebhookType, optionalInfo = {}) { |
|
|
|
public async sendMsg(message: string, type: WebhookType, optionalInfo = {}) { |
|
|
|
const now = Date.now(); |
|
|
|
const now = Date.now(); |
|
|
|
const infoAlert: InfoMeta = { |
|
|
|
const infoAlert: InfoMeta = { |
|
|
|
params: optionalInfo, |
|
|
|
params: optionalInfo, |
|
|
@ -195,7 +199,11 @@ export class AlertService { |
|
|
|
from: now, |
|
|
|
from: now, |
|
|
|
to: now |
|
|
|
to: now |
|
|
|
} |
|
|
|
} |
|
|
|
sendNotification({ message, meta: infoAlert }); |
|
|
|
try { |
|
|
|
|
|
|
|
await sendNotification({ message, meta: infoAlert }) |
|
|
|
|
|
|
|
} catch(error) { |
|
|
|
|
|
|
|
console.error(`can't send notification ${error}`); |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public sendGrafanaAvailableWebhook() { |
|
|
|
public sendGrafanaAvailableWebhook() { |
|
|
|