Skip to content

ruler: fix the /api/v1/rules endpoint#1773

Merged
bwplotka merged 4 commits intothanos-io:masterfrom
simonpasquier:fix-rules-api
Nov 22, 2019
Merged

ruler: fix the /api/v1/rules endpoint#1773
bwplotka merged 4 commits intothanos-io:masterfrom
simonpasquier:fix-rules-api

Conversation

@simonpasquier
Copy link
Copy Markdown
Contributor

@simonpasquier simonpasquier commented Nov 21, 2019

Closes #1189

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Fixed the switch type in the rules handler because alerting rules are instances of *rules.AlertingRule, not thanosrule.AlertingRule. This is because the rules are returned from the Prometheus rule managers and have no notion of PartialResponseStrategy.

Verification

The /api/v1/rules and /api/v1/alerts endpoints are now covered by the end-to-end tests.

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@simonpasquier simonpasquier changed the title test/e2e: test alerts and rules API endpoints ruler: fix the /api/v1/rules endpoint Nov 21, 2019
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
@s-urbaniak
Copy link
Copy Markdown
Contributor

/cc @bwplotka

Copy link
Copy Markdown
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Some comments, otherwise LGTM (:

expr1, err := promql.ParseExpr(`absent(test_metric3) != 1`)
if err != nil {
m.testing.Fatalf("unable to parse alert expression: %s", err)
panic(fmt.Sprintf("unable to parse alert expression: %s", err))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why panicking in tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because it should never fail but I can revert if you prefer.

CHANGELOG.md Outdated
- [#1669](https://github.com/thanos-io/thanos/pull/1669) Fixed store sharding. Now it does not load excluded meta.jsons and load/fetch index-cache.json files.
- [#1670](https://github.com/thanos-io/thanos/pull/1670) Fixed un-ordered blocks upload. Sidecar now uploads the oldest blocks first.
- [#1568](https://github.com/thanos-io/thanos/pull/1709) Thanos Store now retains the first raw value of a chunk during downsampling to avoid losing some counter resets that occur on an aggregation boundary.
- [#1773](https://github.com/thanos-io/thanos/pull/1773) Thanos Ruler: fixed the /api/v1/rules endpoint.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we tell users what exactly problem was fixed?

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Copy link
Copy Markdown
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

@bwplotka bwplotka merged commit 40cb634 into thanos-io:master Nov 22, 2019
@s-urbaniak
Copy link
Copy Markdown
Contributor

thanks @bwplotka for the review and @simonpasquier for the contribution! 🎉

@simonpasquier simonpasquier deleted the fix-rules-api branch November 25, 2019 08:51
IKSIN pushed a commit to monitoring-tools/thanos that referenced this pull request Nov 26, 2019
* test/e2e: test alerts and rules API endpoints

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* pkg/rule: fix /api/v1/rules endpoint

Signed-off-by: Simon Pasquier <spasquie@redhat.com>

* Address Bartek's comments

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
Signed-off-by: Aleksey Sin <asin@ozon.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rules api internal failed to assert type of rule

3 participants