mirror of
https://github.com/pushbits/server.git
synced 2025-05-07 14:16:15 +02:00
Handle lables and annotations
This commit is contained in:
parent
d1002b0488
commit
64583e3710
2 changed files with 6 additions and 4 deletions
|
@ -63,7 +63,7 @@ formatting:
|
||||||
|
|
||||||
# This settings are only relevant if you want to use PushBits with alertmanager
|
# This settings are only relevant if you want to use PushBits with alertmanager
|
||||||
alertmanager:
|
alertmanager:
|
||||||
# The name of the entry in the alerts annotations that should be used for the title
|
# The name of the entry in the alerts annotations or lables that should be used for the title
|
||||||
annotationtitle: title
|
annotationtitle: title
|
||||||
# The name of the entry in the alerts annotations that should be used for the message
|
# The name of the entry in the alerts annotations or labels that should be used for the message
|
||||||
annotationmessage: message
|
annotationmessage: message
|
||||||
|
|
|
@ -95,14 +95,16 @@ func (alert *alert) ToNotification(titleAnnotation, messageAnnotation string) mo
|
||||||
|
|
||||||
if titleString, ok := alert.Annotiations[titleAnnotation]; ok {
|
if titleString, ok := alert.Annotiations[titleAnnotation]; ok {
|
||||||
title.WriteString(titleString)
|
title.WriteString(titleString)
|
||||||
|
} else if titleString, ok := alert.Labels[titleAnnotation]; ok {
|
||||||
|
title.WriteString(titleString)
|
||||||
} else {
|
} else {
|
||||||
title.WriteString("Unknown Title")
|
title.WriteString("Unknown Title")
|
||||||
}
|
}
|
||||||
title.WriteString(" - ")
|
|
||||||
title.WriteString(alert.StartsAt)
|
|
||||||
|
|
||||||
if messageString, ok := alert.Annotiations[messageAnnotation]; ok {
|
if messageString, ok := alert.Annotiations[messageAnnotation]; ok {
|
||||||
message.WriteString(messageString)
|
message.WriteString(messageString)
|
||||||
|
} else if messageString, ok := alert.Labels[messageAnnotation]; ok {
|
||||||
|
message.WriteString(messageString)
|
||||||
} else {
|
} else {
|
||||||
message.WriteString("Unknown Message")
|
message.WriteString("Unknown Message")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue