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