Skip to content
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

Merged
merged 7 commits into from Mar 4, 2020

Conversation

Wing924
Copy link
Contributor

@Wing924 Wing924 commented Mar 2, 2020

What this PR does:

Support lastEvaluation and evaluationTime in /api/v1/rules endpoints and make order of groups stable.

Which issue(s) this PR fixes:

Without lastEvaluation and evaluationTime, /api/prom/new/rules show NaN in prometheus UI.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

…oints and make order of groups stable.

Signed-off-by: Wing924 <weihe924stephen@gmail.com>
Signed-off-by: Wing924 <weihe924stephen@gmail.com>
Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, however I have on nit

CHANGELOG.md Outdated
@@ -65,7 +66,7 @@
* [BUGFIX] The gauge `cortex_overrides_last_reload_successful` is now only exported by components that use a `RuntimeConfigManager`. Previously, for components that do not initialize a `RuntimeConfigManager` (such as the compactor) the gauge was initialized with 0 (indicating error state) and then never updated, resulting in a false-negative permanent error state. #2092
* [BUGFIX] Fixed WAL metric names, added the `cortex_` prefix.
* [BUGFIX] Restored histogram `cortex_configs_request_duration_seconds` #2138
* [BUGFIX] Fix wrong syntax for `url` in config-file-reference. #2148
* [ENHANCEMENT] Fix wrong syntax for `url` in config-file-reference. #2148
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've fixed it.

Signed-off-by: Wing924 <weihe924stephen@gmail.com>
@Wing924 Wing924 requested a review from jtlisi March 3, 2020 04:54
Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, one more nit

@@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of Rulers in the ring does not correlate to the number of rule groups being evaluated.

Yes, but it should be no more than len(rulers.Ingesters). This fix is for avoid realloc slice.
if the slice is empty (before my fix), the len and cap is 0. After each append, the len increase 1 but cap will be 0, 2, 2, 4, 4..., which make malloc many times.

Copy link
Contributor

Choose a reason for hiding this comment

The 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!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added the comment.

Signed-off-by: Wing924 <weihe924stephen@gmail.com>
@gouthamve gouthamve merged commit 744a76c into cortexproject:master Mar 4, 2020
@Wing924 Wing924 deleted the rules_api branch March 4, 2020 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants