Fix resolved priority and add priority label switch
This commit is contained in:
parent
a8de2b624b
commit
dd34fbe61a
1 changed files with 18 additions and 10 deletions
|
@ -4,7 +4,7 @@ import { Priority } from '../enum/priority';
|
|||
|
||||
export class GrafanaService {
|
||||
public async postAlert(req: Request): Promise<void> {
|
||||
const messagePriotity = getPriority(req.body.status);
|
||||
const messagePriotity = getPriority(req.body.status, req.body.commonLabels.priority);
|
||||
const messageTitle = req.body.commonLabels.alertname;
|
||||
const messageDescription = req.body.commonAnnotations.summary;
|
||||
const messageTags = getTags(req.body.commonLabels, req.body.status);
|
||||
|
@ -20,12 +20,20 @@ export class GrafanaService {
|
|||
}
|
||||
}
|
||||
|
||||
function getPriority(status: string): Priority {
|
||||
switch (status) {
|
||||
case 'firing':
|
||||
return Priority.URGENT;
|
||||
case 'firing':
|
||||
function getPriority(status: string, priority: string): Priority {
|
||||
if (status == 'resolved') {
|
||||
return Priority.MIN;
|
||||
}
|
||||
|
||||
switch (priority) {
|
||||
case 'low':
|
||||
return Priority.MIN;
|
||||
case 'normal':
|
||||
return Priority.DEFAULT;
|
||||
case 'high':
|
||||
return Priority.HIGH;
|
||||
case 'critical':
|
||||
return Priority.URGENT;
|
||||
default:
|
||||
return Priority.DEFAULT;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue