DeleteAlertmanagerConfig gets the status of an alertmanager instance
(ctx context.Context)
| 1017 | |
| 1018 | // DeleteAlertmanagerConfig gets the status of an alertmanager instance |
| 1019 | func (c *Client) DeleteAlertmanagerConfig(ctx context.Context) error { |
| 1020 | u := c.alertmanagerClient.URL("/api/v1/alerts", nil) |
| 1021 | req, err := http.NewRequest(http.MethodDelete, u.String(), nil) |
| 1022 | if err != nil { |
| 1023 | return fmt.Errorf("error creating request: %v", err) |
| 1024 | } |
| 1025 | |
| 1026 | resp, body, err := c.alertmanagerClient.Do(ctx, req) |
| 1027 | if err != nil { |
| 1028 | return err |
| 1029 | } |
| 1030 | |
| 1031 | if resp.StatusCode == http.StatusNotFound { |
| 1032 | return ErrNotFound |
| 1033 | } |
| 1034 | |
| 1035 | if resp.StatusCode != http.StatusOK { |
| 1036 | return fmt.Errorf("deleting config failed with status %d and error %v", resp.StatusCode, string(body)) |
| 1037 | } |
| 1038 | |
| 1039 | return nil |
| 1040 | } |
| 1041 | |
| 1042 | // SendAlertToAlermanager sends alerts to the Alertmanager API |
| 1043 | func (c *Client) SendAlertToAlermanager(ctx context.Context, alert *model.Alert) error { |