-
Notifications
You must be signed in to change notification settings - Fork 542
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rule Concurrency: Support self references (#10431)
* Rule Concurrency: Support self references After deployment of to dev, we are getting some of these warnings: ``` Cyclic rule dependencies detected, falling back to sequential rule evaluation ``` It turns out to be a recording rule that is self referencing (using `last_over_time` to fall back to its last value). Whenever a rule's unevaluated dependencies consist of only itself, it is OK to be run. A caveat is that if there are two rules recording to a metric with the same name, but with different labels, the dependency tree cannot be built and concurrency is not possible * Warn for all unexpected outcomes
- Loading branch information
1 parent
2a289be
commit 386f2a9
Showing
4 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
pkg/ruler/fixtures/rules_self_and_same_name_reference.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
groups: | ||
- name: self_and_same_name_reference | ||
rules: | ||
# Because of these two rules, this rule group cannot be evaluated concurrently. | ||
# While they are independent they have the same name, and they both self-reference. | ||
# The expressions' labels are not parsed to determine dependencies, only the names. | ||
- record: job:http_requests:rate1m | ||
expr: sum by (job)(rate(http_requests_total{job="job1"}[1m])) or last_over_time(job:http_requests:rate1m{job="job1"}[1m]) | ||
- record: job:http_requests:rate1m | ||
expr: sum by (job)(rate(http_requests_total{job="job2"}[1m])) or last_over_time(job:http_requests:rate1m{job="job2"}[1m]) | ||
|
||
- record: job1:http_requests:rate1m | ||
expr: job:http_requests:rate1m{job="job1"} | ||
- record: job1_cluster1:http_requests:rate1m | ||
expr: job1:http_requests:rate1m{cluster="cluster1"} | ||
- record: job1_cluster2:http_requests:rate1m | ||
expr: job1:http_requests:rate1m{cluster="cluster2"} | ||
- record: job1_cluster1_namespace1:http_requests:rate1m | ||
expr: job1_cluster1:http_requests:rate1m{namespace="namespace1"} | ||
- record: job1_cluster1_namespace2:http_requests:rate1m | ||
expr: job1_cluster1:http_requests:rate1m{namespace="namespace2"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
groups: | ||
- name: self_reference | ||
rules: | ||
# Evaluated concurrently, no dependencies | ||
- record: job:http_requests:rate1m | ||
expr: sum by (job)(rate(http_requests_total[1m])) or last_over_time(job:http_requests:rate1m[1m]) # New value or last value | ||
- record: job:http_requests:rate5m | ||
expr: sum by (job)(rate(http_requests_total[5m])) or last_over_time(job:http_requests:rate5m[5m]) # New value or last value | ||
|
||
# These rules will be grouped into batches of independent rules | ||
- record: job1:http_requests:rate1m | ||
expr: job:http_requests:rate1m{job="job1"} | ||
- record: job1_cluster1:http_requests:rate1m | ||
expr: job1:http_requests:rate1m{cluster="cluster1"} | ||
- record: job1_cluster2:http_requests:rate1m | ||
expr: job1:http_requests:rate1m{cluster="cluster2"} | ||
- record: job1_cluster1_namespace1:http_requests:rate1m | ||
expr: job1_cluster1:http_requests:rate1m{namespace="namespace1"} | ||
- record: job1_cluster1_namespace2:http_requests:rate1m | ||
expr: job1_cluster1:http_requests:rate1m{namespace="namespace2"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters