-
Notifications
You must be signed in to change notification settings - Fork 4
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
Enable Generic Alert Rules #115
Conversation
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.
Good work. I am glad we are moving forward with this.
I am not sure exactly why we need to parse strings to accept up alert rules. Would it not be cleaner and easier to just express the alert rules as python objects rather than strings?
The blocking comment here is the one about the method name.
The point is that we have an add method now which works the same as the I assume you mean to have these generic up/absent rules as an AlertRules object rather than create a new class for this "python object". IIUC then this would require a rework of the AlertRules class to add functionality to combine two AlertRules objects like The commodity here is a Prometheus alert YAML so it makes sense to take an input approximating this format rather than hiding it behind an object. |
The blocking requested changes were accepted and included in the PR
I was not suggesting using some alert rule class; simply |
I like this idea, will implement it |
Issue
Currently, anyone who wants to have up/absent alerts for their charm they would have to do this per charm.
“up” has slightly different semantics between remote-write and scrape:
To help with centralizing the up/absent rules, we need a convenient way to "inject" alerts on the fly.
Solution
Support for generic alerts can be centralised in cos-lib by adding the functionality to add rules from a string in either single-rule or official-rule format. This then allows Prometheus (and Mimir) or Grafana Agent to consume this functionality and have a generic up/absent rule in their library provided by the O11y team using best-practice knowledge. This prevents operators having to make their own up/abesnt rules and potentially not using best-practice alerting methods.
When adding rules from string a custom group name and/or prefix is acceptable which is sanitized according to Prometheus metric name format, replacing illegal characters for underscores.
Example Implementation
Given a rule from string in official-rule format (can also be single-rule format)
Add the rules from string to the existing rule set
Context
Testing Instructions
This is an ops-independent change. See unit tests.
Upgrade Notes