MCPcopy Index your code
hub / github.com/cortexproject/cortex / DeleteAlertmanagerConfig

Method DeleteAlertmanagerConfig

integration/e2ecortex/client.go:1019–1040  ·  view source on GitHub ↗

DeleteAlertmanagerConfig gets the status of an alertmanager instance

(ctx context.Context)

Source from the content-addressed store, hash-verified

1017
1018// DeleteAlertmanagerConfig gets the status of an alertmanager instance
1019func (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
1043func (c *Client) SendAlertToAlermanager(ctx context.Context, alert *model.Alert) error {

Callers 1

TestAlertmanagerStoreAPIFunction · 0.95

Calls 2

StringMethod · 0.65
DoMethod · 0.65

Tested by 1

TestAlertmanagerStoreAPIFunction · 0.76