Compare commits
1 Commits
538673281e
...
8529033bc4
Author | SHA1 | Date | |
---|---|---|---|
8529033bc4 |
@ -12,14 +12,19 @@ import (
|
||||
func HandleAlertmanagerPayloadPost(c *fiber.Ctx) error {
|
||||
payload := template.Data{}
|
||||
if err := c.BodyParser(&payload); err != nil {
|
||||
fmt.Println("Failed to parse payload", err)
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Got alertmanager payload")
|
||||
fmt.Println(len(payload.Alerts))
|
||||
fmt.Println(payload.Alerts)
|
||||
|
||||
for _, alert := range payload.Alerts {
|
||||
message := ""
|
||||
|
||||
fmt.Printf("Status - %s", alert.Status)
|
||||
fmt.Printf("Severity - %s", alert.Labels["severity"])
|
||||
|
||||
if alert.Status == "firing" {
|
||||
switch alert.Labels["severity"] {
|
||||
case "warning":
|
||||
@ -33,7 +38,6 @@ func HandleAlertmanagerPayloadPost(c *fiber.Ctx) error {
|
||||
|
||||
_, err := matrixClient.SendText(id.RoomID(*defaultRoom), message)
|
||||
if err != nil {
|
||||
fmt.Println("Failed sending to Matrix", err)
|
||||
if httpErr, ok := err.(mautrix.HTTPError); ok {
|
||||
return c.Status(httpErr.Response.StatusCode).SendString(httpErr.RespError.Err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user