MCPcopy Create free account
hub / github.com/cortexproject/cortex / GetRules

Method GetRules

pkg/configs/client/client.go:92–115  ·  view source on GitHub ↗

GetRules implements Client

(ctx context.Context, since userconfig.ID)

Source from the content-addressed store, hash-verified

90
91// GetRules implements Client
92func (c ConfigDBClient) GetRules(ctx context.Context, since userconfig.ID) (map[string]userconfig.VersionedRulesConfig, error) {
93 suffix := ""
94 if since != 0 {
95 suffix = fmt.Sprintf("?since=%d", since)
96 }
97 endpoint := fmt.Sprintf("%s/private/api/prom/configs/rules%s", c.URL.String(), suffix)
98 var response *ConfigsResponse
99 err := instrument.CollectedRequest(ctx, "GetRules", configsRequestDuration, instrument.ErrorCode, func(ctx context.Context) error {
100 var err error
101 response, err = doRequest(endpoint, c.Timeout, c.TLSConfig, since)
102 return err
103 })
104 if err != nil {
105 return nil, err
106 }
107 configs := map[string]userconfig.VersionedRulesConfig{}
108 for id, view := range response.Configs {
109 cfg := view.GetVersionedRulesConfig()
110 if cfg != nil {
111 configs[id] = *cfg
112 }
113 }
114 return configs, nil
115}
116
117// GetAlerts implements Client.
118func (c ConfigDBClient) GetAlerts(ctx context.Context, since userconfig.ID) (*ConfigsResponse, error) {

Callers

nothing calls this directly

Calls 3

doRequestFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected