DeleteRuleGroup deletes a rule group.
(namespace string, groupName string)
| 871 | |
| 872 | // DeleteRuleGroup deletes a rule group. |
| 873 | func (c *Client) DeleteRuleGroup(namespace string, groupName string) error { |
| 874 | // Create HTTP request |
| 875 | req, err := http.NewRequest("DELETE", fmt.Sprintf("http://%s/api/prom/rules/%s/%s", c.rulerAddress, url.PathEscape(namespace), url.PathEscape(groupName)), nil) |
| 876 | if err != nil { |
| 877 | return err |
| 878 | } |
| 879 | |
| 880 | req.Header.Set("Content-Type", "application/yaml") |
| 881 | req.Header.Set("X-Scope-OrgID", c.orgID) |
| 882 | |
| 883 | ctx, cancel := context.WithTimeout(context.Background(), c.timeout) |
| 884 | defer cancel() |
| 885 | |
| 886 | // Execute HTTP request |
| 887 | res, err := c.httpClient.Do(req.WithContext(ctx)) |
| 888 | if err != nil { |
| 889 | return err |
| 890 | } |
| 891 | |
| 892 | defer res.Body.Close() |
| 893 | return nil |
| 894 | } |
| 895 | |
| 896 | // DeleteRuleNamespace deletes all the rule groups (and the namespace itself). |
| 897 | func (c *Client) DeleteRuleNamespace(namespace string) error { |