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

Add ability to specify rule group interval #367

Open
KalenWessel opened this issue Aug 8, 2022 · 2 comments · Fixed by linode-obs/sloth#1 or r3code/sloth#3 · May be fixed by #515
Open

Add ability to specify rule group interval #367

KalenWessel opened this issue Aug 8, 2022 · 2 comments · Fixed by linode-obs/sloth#1 or r3code/sloth#3 · May be fixed by #515

Comments

@KalenWessel
Copy link

I'm wanting to override the global default interval value with a rule_group interval value. When generating the rules via sloth I do not see the ability to set this.

@slok
Copy link
Owner

slok commented Oct 27, 2022

Hi @KalenWessel!

Sloth doesn't support this currently. But is a very nice point and addition. definitely, Sloth should support this.

Thanks for raising this up!

wbollock added a commit to wbollock/sloth that referenced this issue Jun 13, 2023
This allows for more expensive SLO recording rules by letting users
create a custom Prometheus `rule_group.interval`.

https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group

Now instead of all rule groups using the default global evaluation
interval, a custom interval will be set on all sets of recording rules
for an SLO.

Resolves: slok#367
wbollock added a commit to wbollock/sloth that referenced this issue Jun 14, 2023
This allows for more expensive SLO recording rules by letting users
create a custom Prometheus `rule_group.interval`.

https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group

Now instead of all rule groups using the default global evaluation
interval, a custom interval can be set on all sets of recording rules
for an SLO.

If no `interval` is set then the global default will be assumed,
matching current Sloth behavior.

Resolves: slok#367
wbollock added a commit to wbollock/sloth that referenced this issue Jul 3, 2023
This allows for more expensive SLO recording rules by letting users
create a custom Prometheus `rule_group.interval`.

https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group

Now instead of all rule groups using the default global evaluation
interval, a custom interval can be set on all sets of recording rules
for an SLO.

If no `interval` is set then the global default will be assumed,
matching current Sloth behavior.

Resolves: slok#367
@wbollock wbollock linked a pull request Jul 3, 2023 that will close this issue
@wbollock
Copy link

wbollock commented Jul 3, 2023

@slok @KalenWessel I opened up #515, would appreciate any feedback!

r3code added a commit to r3code/sloth that referenced this issue Jul 13, 2023
* feat: adjustable rule_group interval

This allows for more expensive SLO recording rules by letting users
create a custom Prometheus `rule_group.interval`.

https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group

Now instead of all rule groups using the default global evaluation
interval, a custom interval can be set on all sets of recording rules
for an SLO.

If no `interval` is set then the global default will be assumed,
matching current Sloth behavior.

Resolves: slok#367

* docs: add example file for custom rule groups

* ref: only append RuleGroupInterval when not empty

Related to how the unit test coverage works, this will make sure
RuleGroupInterval is not appended to RuleGroups unless it is defined and
not empty.

Not requring the `yaml` file does an okay job of this but expliclity
writing the rules without RuleGroupInterval is safer.

It's a bit ugly and repetitive but I think that's just how Go works..

* test: update tests for custom rule_group interval

This updates tests include `interval`'s and also includes a test to make
sure the rules render correctly when interval is not included.

* ref: add rule intervals per rule type

Instead of a singular global default, now a rule_group interval can be
set for every individual type of rule_group Sloth generates.

The generic, `interval:all` rule will also stay and can "fill in" any missing per-rule
group defaults. Along with the default behavior of doing nothing if no
`interval` is specified.

* test: add tests for custom rule group intervals

Specific ones and general/specific combined

* chore: update example for custom rule groups

* docs: finish comments

Co-authored-by: Will Hegedus <will@wbhegedus.me>

* ref: rule interval groups less repetitive

* chore: golint else outindent

---------

Co-authored-by: Will Bollock <wbollock@linode.com>
Co-authored-by: Will Bollock <wbollock@gmail.com>
Co-authored-by: Will Hegedus <will@wbhegedus.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants