Repository navigation
Silence CRD Design Proposal - #5485
mcbenjemaa wants to merge 41 commits into
Conversation
xiu
left a comment
There was a problem hiding this comment.
Exciting! 🥳 Added a few comments, feel free to discard if I misunderstood.
| `app: test-alertmanager`. | ||
|
|
||
| * `selector` used to select which Kubernetes Service to use as an Alertmanager API. | ||
| * `validUntil` to define the expiration of the silence. |
There was a problem hiding this comment.
Would it make sense to have silences that stay active so long as the resource exists? For instance, if validUntil is undefined, then the Silence stays active. If it is, the Silence expires at the date defined.
There was a problem hiding this comment.
Yeah, I'm guessing if we can add a default maximum days if the user has not defined the validUntil
There was a problem hiding this comment.
There is no way to create a Silence which never expires in Alertmanager, so far we used a dirty hacked by shifting the expiry date 1000 years into the future.
There was a problem hiding this comment.
we can make the field expiresAt required so :)
There was a problem hiding this comment.
The implementation could also keep the silence active when this field is not defined. I have no strong opinion on this.
There was a problem hiding this comment.
However, how do we handle silence overwrite?
There was a problem hiding this comment.
Silence operator would update them. The silence id in alertmanager would be kept in the status
There was a problem hiding this comment.
Great! Can you add that to the proposal? I guess in the How section.
TheoBrigitte
left a comment
There was a problem hiding this comment.
I like the direction here 🚀
810e508 to
04a3b6f
Compare
ArthurSens
left a comment
There was a problem hiding this comment.
Thanks for raising the PR :) It is a good start!
And sorry about a lot of NIT reviews, at first glance, a reader can feel that something is trying to be sold here, instead of just stating facts.
In a design document, we could provide the reader with just plain information and he/she will be the one making conclusions about how bad the current situation is and how good it can become.
| Additionally, having a new component in the stack and keeping it maintained is not always ideal (said the folks at [Giant Swarm](https://giantswarm.io) the owners of [silence-operator](https://github.com/giantswarm/silence-operator)), | ||
| because that would require us to fully manage this component as of any managed app (monitoring, logging, alerting etc..). | ||
| Having the Silence CRD as part of prometheus-operator provides users with a better experience: there is no need to install another operator or build a system on top of it to provide that functionality. |
There was a problem hiding this comment.
I can see that having 2 components on the stack is more complex than 1, but here we're moving one component by making the other slightly more complex as well, i.e. users still need to monitor Prometheus-operator and Alertmanager to understand if their Silence CRs are behaving as expected.
Of course, I'm saying this without any experience with the silence-operator 😅, it might as well be a super simple component and I'm here making a fuss :P
Could you tell us a bit more about the common failure modes that you've found while using it at Giantswarm?
There was a problem hiding this comment.
We didn't have complex failures or monitoring for this component, we just need to have an alert that triggers if a certain Silence reconciliation failed.
There was a problem hiding this comment.
As @mcbenjemaa said, we have only 2 possible failure scenarios in the silence-operator, either the silence cannot be reconcilied with alertmanager (which almost never happen because we have a small Silence CRD API) or the flux kustomization pulling the silences if failing.
If this hits into prometheus-operator, the failure modes would roughly be the same in my opinion
There was a problem hiding this comment.
If I want to summarize, you're saying that users are free to use if they see fit but they can also continue to manage their silences "manually"?
| This example doesn't list all the fields that are offered by prometheus. The implementation of all the fields will be | ||
| done in an iterative process and as such, the expectation is not for all of them to be implemented in the first version. |
There was a problem hiding this comment.
I might be wrong, but the missing fields are just "Created By" and "Comment", aren't they? Which doesn't seem to offer a big challenge to implement when compared to expiration handling.
Couldn't we just add all fields all at once?
There was a problem hiding this comment.
we can add them as annotation, or you prefer fields under the spec?
There was a problem hiding this comment.
Any thoughts here?
simonpasquier
left a comment
There was a problem hiding this comment.
Thanks for putting this together! It helps a lot to understand the use cases :)
Could you a high-level overview of how the silences will be reconciled (or rather how the silence operator does it right now)?
|
|
||
| * Users using CI/CD jobs to manage silences have reported that this is cumbersome, since they need to either expose | ||
| Alertmanager via an ingress or using a service account to connect to the cluster, and this is even more complicated | ||
| in a multi-cluster setup. |
There was a problem hiding this comment.
can you expand a bit on the multi-cluster setup?
Another use case where this would be useful is when enabling AlertmanagerConfig custom resources to offer self-service notifications.
There was a problem hiding this comment.
Another use case where this would be useful is when enabling AlertmanagerConfig custom resources to offer self-service notifications.
what does this mean?
There was a problem hiding this comment.
In GS, our original use case is that we needed to deploy the same silences in multiple clusters from a single source of truth.
Deploying flux is definitely easier on multiple clusters than deploying some internal tooling to sync silences and this is all done from within the cluster so using the alertmanager is enough.
In a CI way (unless you use something like tekton for sure) you would need to have your CI aware about all the different alertmanager URIs, but also have it on every silence which can be expensive depending on the number of clusters you have. Also, if the ci cannot access an alertmanager for some reason, you would need to rerun the CI again
There was a problem hiding this comment.
Another use case where this would be useful is when enabling AlertmanagerConfig custom resources to offer self-service notifications.
what does this mean?
For example in OpenShift, cluster admins can deploy a monitoring stack for application developers who are then able to define:
- scraped targets with ServiceMonitor, PodMonitor and Probe resources.
- recording/alerting rules with PrometheusRule resources.
- alert notifications with AlertmanagerConfig resources.
Having a Silence CRD would allow these users to also manage their notification silences using the same techniques.
| Additionally, having a new component in the stack and keeping it maintained is not always ideal (said the folks at [Giant Swarm](https://giantswarm.io) the owners of [silence-operator](https://github.com/giantswarm/silence-operator)), | ||
| because that would require us to fully manage this component as of any managed app (monitoring, logging, alerting etc..). | ||
| Having the Silence CRD as part of prometheus-operator provides users with a better experience: there is no need to install another operator or build a system on top of it to provide that functionality. |
There was a problem hiding this comment.
If I want to summarize, you're saying that users are free to use if they see fit but they can also continue to manage their silences "manually"?
| spec: | ||
| selector: | ||
| app: test-alertmanager | ||
| expiresAt: "2023-06-01" |
There was a problem hiding this comment.
Don't we need a datetime here?
There was a problem hiding this comment.
I think we need a format supported by the Alertmanager API.
So, we will accept a string and validate that's a date or DateTime.
There was a problem hiding this comment.
The date is more of a remnant of our internal implementation but adding time definitely makes sense
There was a problem hiding this comment.
I will check this
| ``` | ||
|
|
||
| The above resource will result in creating a silence in the Alertmanager with label selector, | ||
| `app: test-alertmanager`. |
There was a problem hiding this comment.
I don't think that it's the correct model. This approach would allow any user to create silences on any Alertmanager in the cluster.
IMHO we need .spec.silenceSelector and .spec.silenceNamespaceSelector in the Alertmanager CRD.
There was a problem hiding this comment.
From my point of view, I dont think this is a good idea .spec.silenceSelector and .spec.silenceNamespaceSelector in the Alertmanager CRD.
As silences are An API resource and it's not a config like AlertmanagerConfig.
Having the selector in the Silence CR, make it easier to select which Alertmanager to Use.
What do you think?
There was a problem hiding this comment.
From a security point of view, I guess we can limit the users by RBAC who can Create/Update Silences.
There was a problem hiding this comment.
If you emphasize using this approach, then we need to use both selectors in Alertmanager CRD.
and remove this selector.
There was a problem hiding this comment.
I also thinks this makes more sense because silence creators should not be aware of which alertmanager they want to target
There was a problem hiding this comment.
This is an interesting problem! I agree with @simonpasquier but I also see the other side where it would be great if the user did not have to care about which AM they are targeting.
For the sake of discussion, if we were to only have selector, would it be feasible for the operator to only accept Silences in the same place as the PrometheusRule or would this be too limiting?
There was a problem hiding this comment.
We will just go with selectors in the alertmanager for now:
[...]
spec:
silenceSelector: ...
silenceNamespaceSelector: ...| * Users who want to manage silences the same way as for services running within the Kubernetes cluster. | ||
| * Users who want a supported Kubernetes way of silences outside the Kubernetes cluster |
There was a problem hiding this comment.
These two sound the same. AFAIC as @QuentinBisson mentioned one of the goals is for users who manage their clusters strictly through GitOps
There was a problem hiding this comment.
But, I have updated it
| ``` | ||
|
|
||
| The above resource will result in creating a silence in the Alertmanager with label selector, | ||
| `app: test-alertmanager`. |
There was a problem hiding this comment.
This is an interesting problem! I agree with @simonpasquier but I also see the other side where it would be great if the user did not have to care about which AM they are targeting.
For the sake of discussion, if we were to only have selector, would it be feasible for the operator to only accept Silences in the same place as the PrometheusRule or would this be too limiting?
9edca86 to
036d135
Compare
ArthurSens
left a comment
There was a problem hiding this comment.
One thought just came up!
It is not possible to delete Silences in Alertmanager (unless Alertmanager's storage is deleted). The usual workflow is just expiring silence rules.
Let's say that a user deploys a new Silence CR, and it eventually gets expired. The user now wants this same silence active again. Would he/she delete the previous CR and create a new one? Would he/she just change the expiration date at the deployed CR? What's the user story that you're imagining?
|
Hey, Don't hesitate to add your reviews |
|
any more reviews? |
|
This is ready for merge. |
xiu
left a comment
There was a problem hiding this comment.
Sorry for being late 😅 I noticed a few nits but all in all it looks good to me!
Co-authored-by: Guillaume Hérail <[email protected]>
Co-authored-by: Guillaume Hérail <[email protected]>
Co-authored-by: Guillaume Hérail <[email protected]>
Co-authored-by: Guillaume Hérail <[email protected]>
|
Hey Folks, can we proceed to merge this? |
simonpasquier
left a comment
There was a problem hiding this comment.
Sorry for the lag on this one. I reviewed the latest version. Can you add more details on how the silence resources will be reconciled in the Alertmanager API?
|
|
||
| Prometheus-operator does not provide a way to automate the management of Alertmanager silences and there is no current standard/best practice way to do that. | ||
| Moreover, setting an automation to manage silences has been reported as cumbersome by multiple users. | ||
| or an additional operator that does the job e.g. [silence-operator](https://github.com/giantswarm/silence-operator). |
There was a problem hiding this comment.
this part doesn't read properly with the previous line.
There was a problem hiding this comment.
let me rephrase it.
| * Teams have to build an automation to add silences in a centralized manner | ||
| * There is no input validation in CI, which can lead to an invalid silence configuration | ||
| * Teams need to manage expiration on their own | ||
| * If a silence was deleted by accident, it will be permanent. |
There was a problem hiding this comment.
as @ArthurSens pointed out, the slience isn't deleted from the Alertmanager db (only the end date is updated to be in the past). Hence the sentence is a bit confusing.
There was a problem hiding this comment.
so we need to delete this point or rephrase it?
| Using Alertmanager API Directly comes with drawbacks: | ||
|
|
||
| * Teams have to build an automation to add silences in a centralized manner | ||
| * There is no input validation in CI, which can lead to an invalid silence configuration |
There was a problem hiding this comment.
The API will validate the request though so I'm not sure that it's a strong point.
There was a problem hiding this comment.
This means if you're using CI, it doesn't support validation prior to sending it to the API.
pre-validation is a benefit in this case.
|
|
||
| ## Pitfalls of the current solution | ||
|
|
||
| Using Alertmanager API Directly comes with drawbacks: |
There was a problem hiding this comment.
I would add "users need access to the Alertmanager API which means that you need to care about authentication/authorization".
|
|
||
| * This proposal do not cover automatic cleanup of expired Silence CRs | ||
| * Refactoring of the other CRDs is not in scope for the first version | ||
| * Adding silences to a remote Alertmanager cluster |
There was a problem hiding this comment.
not sure to understand this one. Is it about creating silences on an Alertmanager cluster not managed by the operator?
There was a problem hiding this comment.
yes, we will not cover adding silences to a remote alertmanager, at least not in the same cluster.
There was a problem hiding this comment.
It can actually be easily achieved with optional field in the CRD for alertmanager url/auth/etc.
If it's not provided operator would take default one from config
| - `regex` - Whether to match on equality (false) or regular-expression (true). Deprecated as of AlertManager >= v0.22.0 where a user should use MatchType instead. | ||
|
|
||
| This example doesn't list all the fields that are offered by Alertmanager. The implementation of all the fields will be | ||
| done in an iterative process and as such, the expectation is not for all of them to be implemented in the first version. |
There was a problem hiding this comment.
I believe that the comment field at least is mandatory in the first place.
There was a problem hiding this comment.
comment field in the silence?
There was a problem hiding this comment.
Can we add CRD schema to the proposal?
I've posted mine above, I think it would be more transparent for everyone
There was a problem hiding this comment.
I think we should leave the schema to the implementation. We can definitely put some example uses but they shouldn't mandate how the API will look like later.
| ``` | ||
|
|
||
| Additionally, the silence-controller will handle `Silences` overwrites. | ||
| After having successfully created a silence, the silence id will be kept in the status sub-resource: |
There was a problem hiding this comment.
we could have the same silence being selected by different Alertmanager resources so this approach will not work out of the box.
There was a problem hiding this comment.
but. we are going to add silenceSelector and silenceNamespaceSelector to the alertmanager CRD
Co-authored-by: Simon Pasquier <[email protected]>
Co-authored-by: Simon Pasquier <[email protected]>
|
This pull request is being closed because it had no activity in the last 180 days. This is not a signal from the maintainers that the PR has no value. We appreciate the time and effort that you put into this work. If you're willing to re-open it, the maintainers will do their best to review it. |
|
Can we reopen this PR, please |
|
For sure) |
|
@mcbenjemaa @simonpasquier can you please reopen the draft |
|
This pull request is being closed because it had no activity in the last 180 days. This is not a signal from the maintainers that the PR has no value. We appreciate the time and effort that you put into this work. If you're willing to re-open it, the maintainers will do their best to review it. |
Proposes a Silence custom resource for prometheus-operator, so that Alertmanager silences can be managed declaratively through the Kubernetes API rather than only through the Alertmanager UI or REST API. Supersedes the proposal in prometheus-operator#7798, and builds on the original in prometheus-operator#5485 and the API review in prometheus-operator#7806. The status subresource follows the accepted configuration-resource convention, with the Alertmanager-assigned UUID as its one addition: the silence API is not declarative, so the handle it returns on creation is the only way to address a silence later, and it cannot be re-derived. Related: prometheus-operator#5452, prometheus-operator#2398, prometheus-operator#5836 Co-authored-by: Mohamed Chiheb Ben Jemaa <[email protected]> Co-authored-by: Daniel Mellado <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Nigel Smith <[email protected]>
Proposes a Silence custom resource for prometheus-operator, so that Alertmanager silences can be managed declaratively through the Kubernetes API rather than only through the Alertmanager UI or REST API. Supersedes the proposal in prometheus-operator#7798, and builds on the original in prometheus-operator#5485 and the API review in prometheus-operator#7806. The status subresource follows the accepted configuration-resource convention, with the Alertmanager-assigned UUID as its one addition: the silence API is not declarative, so the handle it returns on creation is the only way to address a silence later, and it cannot be re-derived. Adds amtool and the two author handles to the spell-check dictionary, following the existing convention for contributor names. Related: prometheus-operator#5452, prometheus-operator#2398, prometheus-operator#5836 Co-authored-by: Mohamed Chiheb Ben Jemaa <[email protected]> Co-authored-by: Daniel Mellado <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Nigel Smith <[email protected]>
Proposes a Silence custom resource for prometheus-operator, so that Alertmanager silences can be managed declaratively through the Kubernetes API rather than only through the Alertmanager UI or REST API. Supersedes the proposal in prometheus-operator#7798, and builds on the original in prometheus-operator#5485 and the API review in prometheus-operator#7806. The status subresource follows the accepted configuration-resource convention, with the Alertmanager-assigned UUID as its one addition: the silence API is not declarative, so the handle it returns on creation is the only way to address a silence later, and it cannot be re-derived. Adds amtool and the two author handles to the spell-check dictionary, following the existing convention for contributor names. Related: prometheus-operator#5452, prometheus-operator#2398, prometheus-operator#5836 Co-authored-by: Mohamed Chiheb Ben Jemaa <[email protected]> Co-authored-by: Daniel Mellado <[email protected]> Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Nigel Smith <[email protected]>
Description
Design document for the Proposal of adding Silence CRD.
Type of change
What type of changes does your code introduce to the Prometheus operator? Put an
xin the box that apply.CHANGE(fix or feature that would cause existing functionality to not work as expected)FEATURE(non-breaking change which adds functionality)BUGFIX(non-breaking change which fixes an issue)ENHANCEMENT(non-breaking change which improves existing functionality)NONE(if none of the other choices apply. Example, tooling, build system, CI, docs, etc.)Changelog entry
Please put a one-line changelog entry below. This will be copied to the changelog file during the release process.