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

Method listRulesNoSharding

pkg/ruler/ruler.go:901–925  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

899}
900
901func (r *Ruler) listRulesNoSharding(ctx context.Context) (map[string]rulespb.RuleGroupList, map[string]rulespb.RuleGroupList, error) {
902 allRuleGroups, err := r.store.ListAllRuleGroups(ctx)
903 if err != nil {
904 return nil, nil, err
905 }
906 ruleGroupCounts := make(map[string]int, len(allRuleGroups))
907 for userID, groups := range allRuleGroups {
908 ruleGroupCounts[userID] = len(groups)
909 disabledRuleGroupsForUser := r.limits.DisabledRuleGroups(userID)
910 if len(disabledRuleGroupsForUser) == 0 {
911 continue
912 }
913 filteredGroupsForUser := rulespb.RuleGroupList{}
914 for _, group := range groups {
915 if !ruleGroupDisabled(group, disabledRuleGroupsForUser) {
916 filteredGroupsForUser = append(filteredGroupsForUser, group)
917 } else {
918 level.Info(r.logger).Log("msg", "rule group disabled", "name", group.Name, "namespace", group.Namespace, "user", group.User)
919 }
920 }
921 allRuleGroups[userID] = filteredGroupsForUser
922 }
923 r.ruleGroupMetrics.UpdateRuleGroupsInStore(ruleGroupCounts)
924 return allRuleGroups, nil, nil
925}
926
927func (r *Ruler) listRulesShardingDefault(ctx context.Context) (map[string]rulespb.RuleGroupList, map[string]rulespb.RuleGroupList, error) {
928 configs, err := r.store.ListAllRuleGroups(ctx)

Callers 1

listRulesMethod · 0.95

Calls 5

ruleGroupDisabledFunction · 0.85
ListAllRuleGroupsMethod · 0.65
DisabledRuleGroupsMethod · 0.65
LogMethod · 0.45

Tested by

no test coverage detected