Skip to content

Commit

Permalink
Skip summary for slack alerts too
Browse files Browse the repository at this point in the history
  • Loading branch information
manugarg committed Oct 17, 2023
1 parent f4bef47 commit 4905408
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions probes/alerting/notifier/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"net/http"
"os"

Expand Down Expand Up @@ -97,7 +98,8 @@ func (c *Client) Notify(ctx context.Context, alertFields map[string]string) erro

// check status code, return error if not 200
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Slack webhook returned status code %d", resp.StatusCode)
b, _ := io.ReadAll(resp.Body)
return fmt.Errorf("slack webhook returned error; statusCode: %d, response: %s", resp.StatusCode, string(b))
}

return nil
Expand All @@ -106,6 +108,6 @@ func (c *Client) Notify(ctx context.Context, alertFields map[string]string) erro
// createMessage creates a new Slack webhook message, from the alertFields
func createMessage(alertFields map[string]string) webhookMessage {
return webhookMessage{
Text: alertFields["details"] + "\n\nDetails:\n" + alertinfo.FieldsToString(alertFields, "details"),
Text: alertFields["details"] + "\n\nDetails:\n" + alertinfo.FieldsToString(alertFields, "details", "summary"),
}
}

0 comments on commit 4905408

Please sign in to comment.