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

Method GetRules

pkg/ruler/ruler.go:1109–1128  ·  view source on GitHub ↗

GetRules retrieves the running rules from this ruler and all running rulers in the ring if sharding is enabled

(ctx context.Context, rulesRequest RulesRequest)

Source from the content-addressed store, hash-verified

1107// GetRules retrieves the running rules from this ruler and all running rulers in the ring if
1108// sharding is enabled
1109func (r *Ruler) GetRules(ctx context.Context, rulesRequest RulesRequest) (*RulesResponse, error) {
1110 userID, err := users.TenantID(ctx)
1111 if err != nil {
1112 return nil, fmt.Errorf("no user id found in context")
1113 }
1114
1115 if r.cfg.EnableSharding {
1116 resp, err := r.getShardedRules(ctx, userID, rulesRequest)
1117 if resp == nil {
1118 return &RulesResponse{
1119 Groups: make([]*GroupStateDesc, 0),
1120 NextToken: "",
1121 }, err
1122 }
1123 return resp, err
1124 }
1125
1126 response, err := r.getLocalRules(userID, rulesRequest, false)
1127 return &response, err
1128}
1129
1130func (r *Ruler) getLocalRules(userID string, rulesRequest RulesRequest, includeBackups bool) (RulesResponse, error) {
1131 groups := r.manager.GetRules(userID)

Callers

nothing calls this directly

Calls 3

getShardedRulesMethod · 0.95
getLocalRulesMethod · 0.95
TenantIDFunction · 0.92

Tested by

no test coverage detected