New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support lastEvaluation
and evaluationTime
in /api/v1/rules
endpoints and make order of groups stable.
#2196
Changes from 2 commits
6405edb
49dc6a7
b65195c
0ce2367
d60f70c
db830cb
23cb5fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -491,10 +491,12 @@ func (r *Ruler) getLocalRules(userID string) ([]*rules.RuleGroupDesc, error) { | |
for _, group := range groups { | ||
interval := group.Interval() | ||
groupDesc := &rules.RuleGroupDesc{ | ||
Name: group.Name(), | ||
Namespace: strings.TrimPrefix(group.File(), prefix), | ||
Interval: interval, | ||
User: userID, | ||
Name: group.Name(), | ||
Namespace: strings.TrimPrefix(group.File(), prefix), | ||
Interval: interval, | ||
User: userID, | ||
EvaluationTimestamp: group.GetEvaluationTimestamp(), | ||
EvaluationDuration: group.GetEvaluationDuration(), | ||
} | ||
for _, r := range group.Rules() { | ||
lastError := "" | ||
|
@@ -521,23 +523,27 @@ func (r *Ruler) getLocalRules(userID string) ([]*rules.RuleGroupDesc, error) { | |
}) | ||
} | ||
ruleDesc = &rules.RuleDesc{ | ||
State: rule.State().String(), | ||
Alert: rule.Name(), | ||
Alerts: alerts, | ||
Expr: rule.Query().String(), | ||
For: rule.Duration(), | ||
Labels: client.FromLabelsToLabelAdapters(rule.Labels()), | ||
Annotations: client.FromLabelsToLabelAdapters(rule.Annotations()), | ||
Health: string(rule.Health()), | ||
LastError: lastError, | ||
Expr: rule.Query().String(), | ||
Alert: rule.Name(), | ||
For: rule.Duration(), | ||
Labels: client.FromLabelsToLabelAdapters(rule.Labels()), | ||
Annotations: client.FromLabelsToLabelAdapters(rule.Annotations()), | ||
State: rule.State().String(), | ||
Health: string(rule.Health()), | ||
LastError: lastError, | ||
Alerts: alerts, | ||
EvaluationTimestamp: rule.GetEvaluationTimestamp(), | ||
EvaluationDuration: rule.GetEvaluationDuration(), | ||
} | ||
case *promRules.RecordingRule: | ||
ruleDesc = &rules.RuleDesc{ | ||
Record: rule.Name(), | ||
Expr: rule.Query().String(), | ||
Labels: client.FromLabelsToLabelAdapters(rule.Labels()), | ||
Health: string(rule.Health()), | ||
LastError: lastError, | ||
Record: rule.Name(), | ||
Expr: rule.Query().String(), | ||
Labels: client.FromLabelsToLabelAdapters(rule.Labels()), | ||
Health: string(rule.Health()), | ||
LastError: lastError, | ||
EvaluationTimestamp: rule.GetEvaluationTimestamp(), | ||
EvaluationDuration: rule.GetEvaluationDuration(), | ||
} | ||
default: | ||
return nil, errors.Errorf("failed to assert type of rule '%v'", rule.Name()) | ||
|
@@ -560,7 +566,7 @@ func (r *Ruler) getShardedRules(ctx context.Context, userID string) ([]*rules.Ru | |
return nil, fmt.Errorf("unable to inject user ID into grpc request, %v", err) | ||
} | ||
|
||
rgs := []*rules.RuleGroupDesc{} | ||
rgs := make([]*rules.RuleGroupDesc, 0, len(rulers.Ingesters)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need this change. The number of Rulers in the ring does not correlate to the number of rule groups being evaluated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, but it should be no more than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a comment for the same? I'll merge it after! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added the comment. |
||
|
||
for _, rlr := range rulers.Ingesters { | ||
conn, err := grpc.Dial(rlr.Addr, grpc.WithInsecure()) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem related to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed it.