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 {
|
export class GrafanaService {
|
||||||
public async postAlert(req: Request): Promise<void> {
|
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 messageTitle = req.body.commonLabels.alertname;
|
||||||
const messageDescription = req.body.commonAnnotations.summary;
|
const messageDescription = req.body.commonAnnotations.summary;
|
||||||
const messageTags = getTags(req.body.commonLabels, req.body.status);
|
const messageTags = getTags(req.body.commonLabels, req.body.status);
|
||||||
|
@ -20,12 +20,20 @@ export class GrafanaService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPriority(status: string): Priority {
|
function getPriority(status: string, priority: string): Priority {
|
||||||
switch (status) {
|
if (status == 'resolved') {
|
||||||
case 'firing':
|
|
||||||
return Priority.URGENT;
|
|
||||||
case 'firing':
|
|
||||||
return Priority.MIN;
|
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:
|
default:
|
||||||
return Priority.DEFAULT;
|
return Priority.DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue