Skip to content

feat: add initial silence crd - #7806

Closed
danielmellado wants to merge 1 commit into
prometheus-operator:mainfrom
danielmellado:add_silence_crd
Closed

danielmellado wants to merge 1 commit into
prometheus-operator:mainfrom
danielmellado:add_silence_crd

Conversation

@danielmellado

Copy link
Copy Markdown
Contributor

Description

This commit implements the first implementation of the Silence CRD
proposed in [1]. It follows existing prometheus-operator patternsfrom
other CRDs and proposes the new api to v1alpha1.

[1] #7798

Type of change

What type of changes does your code introduce to the Prometheus operator? Put an x in 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.)

}

// SilenceStatus tracks the synchronization state across multiple Alertmanager instances
type SilenceStatus struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since a Silence can be selected by several Alertmanager resources (*), we need a structure that allows for it. You can take a look at https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/proposals/accepted/202501-configuration-object-status-subresource.md

(*) the most likely case is that a Silence resource is associated to a single Alertmanager resource but we can't exclude the possibilty.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(nit) I would defer the example for now.

// Comment provides context about the silence, typically explaining
// the reason for creating it (e.g., "Scheduled maintenance window").
// +optional
Comment string `json:"comment,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't Comment be always required?


// ExpiresAt specifies when the silence expires and alert notifications
// resume. This field is required to prevent indefinite silences.
ExpiresAt metav1.Time `json:"expiresAt"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here.

// AlertmanagerRef references a specific Alertmanager instance to apply this silence to.
// If not specified, the silence applies to all Alertmanager instances in the namespace.
// +optional
AlertmanagerRef *AlertmanagerRef `json:"alertmanagerRef,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As mentioned in the proposal PR, I'm not sure that we want to allow this.

// SilenceSynced indicates the silence is synchronized across all target Alertmanager instances.
SilenceSynced SilenceConditionType = "Synced"
// SilenceFailed indicates an error occurred during Alertmanager API interaction.
SilenceFailed SilenceConditionType = "Failed"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the difference between synced, ready and failed conditions? Can we trim down to only 1 condition (e.g. Ready) which would be True when the silence is applied and False otherwise?

This commit implements the first implementation of the Silence CRD
proposed in [1]. It follows existing prometheus-operator patternsfrom
other CRDs and proposes the new api to v1alpha1.

[1] prometheus-operator#7798

Signed-off-by: Daniel Mellado <[email protected]>
Co-authored-by: Mohamed Chiheb Ben Jemaa <[email protected]>
Signed-off-by: Daniel Mellado <[email protected]>
// +required
Comment string `json:"comment"`
// expiresAt specifies when the silence expires and alert notifications
// resume. This field is required to prevent indefinite silences.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// resume. This field is required to prevent indefinite silences.
// resume. This field is required because Alertmanager requires an end date for silences.

}

// SilenceSpec defines the desired state of a Silence.
type SilenceSpec struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we likely need a "created by" field since it's required by Alertmanager API.

// It corresponds to the metadata generation field, indicating whether the
// status reflects the latest changes to the resource.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

observedGeneration is at the binding level, same for conditions.

Name string `json:"name"`
// namespace is the namespace of the Alertmanager resource.
// +required
Namespace string `json:"namespace"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we need group and resource fields too.

// silenceID is the unique identifier of the silence in the Alertmanager API.
// This is populated after the silence is successfully created.
// +optional
SilenceID string `json:"silenceID,omitempty"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For now maybe we can stop at the minimal information: the bound alertmanager instance + the set of conditions?

@github-actions github-actions Bot added the stale label Nov 29, 2025
@github-actions github-actions Bot removed the stale label Mar 16, 2026
@github-actions github-actions Bot added the stale label May 15, 2026
coffeegoesincodecomesout added a commit to coffeegoesincodecomesout/prometheus-operator that referenced this pull request Oct 9, 2026
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]>
coffeegoesincodecomesout added a commit to coffeegoesincodecomesout/prometheus-operator that referenced this pull request Oct 9, 2026
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]>
coffeegoesincodecomesout added a commit to coffeegoesincodecomesout/prometheus-operator that referenced this pull request Oct 9, 2026
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]>
@github-actions

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot closed this Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants