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

Alerting: support the Grafana operator as export format provider #87954

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

theSuess
Copy link
Member

What is this feature?

This PR adds a new export provider for the grafana-operator to the alerting export drawer.

Why do we need this feature?

Configuring alerting rules as-code is very complex. To alleviate this, many users utilize the Modify Export functionality. The YAML export is mostly compatible but requires further modification to be imported as an operator resource. Due to differences in serialization, it also causes CD solutions to trigger changes when there are none.

Who is this feature for?

Users wishing to export their alerting resources as code and use them with the Operator

Which issue(s) does this PR fix?:

Implements grafana/grafana-operator#1492

Special notes for your reviewer:

Since the operator does not (yet) support Notification Policies & Mute Timings, I've added a way to filter for supported export providers.

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@@ -271,7 +271,7 @@ type AlertRuleExport struct {
ForString *string `json:"-" yaml:"-" hcl:"for"`
Annotations *map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty" hcl:"annotations"`
Labels *map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" hcl:"labels"`
IsPaused bool `json:"isPaused" yaml:"isPaused" hcl:"is_paused"`
IsPaused bool `json:"isPaused,omitempty" yaml:"isPaused,omitempty" hcl:"is_paused"`
Copy link
Member Author

Choose a reason for hiding this comment

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

The OpenAPI Spec has this as not required (= the generated go client has it as omitempty) so I'm reflecting the change here

@@ -287,7 +287,7 @@ type AlertQueryExport struct {

type RelativeTimeRangeExport struct {
FromSeconds int64 `json:"from" yaml:"from" hcl:"from"`
ToSeconds int64 `json:"to" yaml:"to" hcl:"to"`
ToSeconds int64 `json:"to,omitempty" yaml:"to,omitempty" hcl:"to"`
Copy link
Member Author

Choose a reason for hiding this comment

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

The OpenAPI Spec has this as not required (= the generated go client has it as omitempty) so I'm reflecting the change here

...r.spec,
rules: r.spec.rules.map(({ notification_settings, ...rule }: any) => ({
...rule,
for: rule.for.endsWith('m') ? rule.for + '0s' : rule.for,
Copy link
Member Author

Choose a reason for hiding this comment

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

This prevents the change noticed in grafana/grafana-operator#1492

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.

None yet

1 participant