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

Method GetRuleGroups

integration/e2ecortex/client.go:786–817  ·  view source on GitHub ↗

GetRuleGroups gets the configured rule groups from the ruler.

()

Source from the content-addressed store, hash-verified

784
785// GetRuleGroups gets the configured rule groups from the ruler.
786func (c *Client) GetRuleGroups() (map[string][]rulefmt.RuleGroup, error) {
787 // Create HTTP request
788 req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/api/prom/rules", c.rulerAddress), nil)
789 if err != nil {
790 return nil, err
791 }
792 req.Header.Set("X-Scope-OrgID", c.orgID)
793
794 ctx, cancel := context.WithTimeout(context.Background(), c.timeout)
795 defer cancel()
796
797 // Execute HTTP request
798 res, err := c.httpClient.Do(req.WithContext(ctx))
799 if err != nil {
800 return nil, err
801 }
802
803 defer res.Body.Close()
804 rgs := map[string][]rulefmt.RuleGroup{}
805
806 data, err := io.ReadAll(res.Body)
807 if err != nil {
808 return nil, err
809 }
810
811 err = yaml.Unmarshal(data, rgs)
812 if err != nil {
813 return nil, err
814 }
815
816 return rgs, nil
817}
818
819// SetRuleGroup configures the provided rulegroup to the ruler.
820func (c *Client) SetRuleGroup(rulegroup rulefmt.RuleGroup, namespace string) error {

Callers 3

TestRulerAPIFunction · 0.95
TestRulerAPISingleBinaryFunction · 0.95
TestRulerHAEvaluationFunction · 0.95

Calls 4

SetMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65
UnmarshalMethod · 0.45

Tested by 3

TestRulerAPIFunction · 0.76
TestRulerAPISingleBinaryFunction · 0.76
TestRulerHAEvaluationFunction · 0.76