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

[v11.0.x] Alerting: Fix simplified routes '...' groupBy creating invalid routes #86376

Merged
merged 1 commit into from
Apr 16, 2024

Conversation

grafana-delivery-bot[bot]
Copy link
Contributor

Backport 533bed6 from #86006


What is this feature?

This bugfix has the following effects to simplified routing GroupBy:

  1. If any of the given labels are the special label ..., then the generated route will contain only the special label ....
  2. No longer required to contain both grafana_folder and alertname labels. If GroupBy is overridden, any missing required labels will be added during route generation.
  3. Generated route's GroupBy will have the labels sorted consistently: first the required labels followed by any custom labels in sorted order.

Why do we need this feature?

This fixes a bug where selecting ... as a label for simplified routing group by would generate an invalid route according to upstream standards thus preventing any further AM config saves until the simplified route GroupBy ... label was removed.

There were a few ways to go about this fix:

  1. Modifying our copy of upstream validation to allow for GroupBy with mixed ... and other labels.
  2. Modify our notification settings validation to prevent GroupBy with mixed ... and other labels.
  3. Normalize GroupBy by on save.
  4. Normalized GroupBy by on route generation.

Option 4. was chosen as the others have the following cons:

  1. Generated routes risk being incompatible with upstream/remote AM.
  2. Awkward FE UX when using '...'.
  3. Rule definition changing after save and potential pitfalls with TF diff.

With option 4. generated routes stay compatible with external/remote AMs, FE doesn't need to change as we allow mixed '...' with custom labels, and settings we save to db are the same as the ones requested.

In addition, it has the slight benefit of allowing us to hide the internal implementation details of alertname, grafana_folder from the user in the future, since we don't need to send them with every FE or TF request.

Who is this feature for?

Users of simplified routing.

Which issue(s) does this PR fix?:

Fixes #86005, #84073

Peek.2024-04-11.19-27.webm

…#86006)

* Alerting: Fix simplified routes '...' groupBy creating invalid routes

There were a few ways to go about this fix:
1. Modifying our copy of upstream validation to allow this
2. Modify our notification settings validation to prevent this
3. Normalize group by on save
4. Normalized group by on generate

Option 4. was chosen as the others have a mix of the following cons:
- Generated routes risk being incompatible with upstream/remote AM
- Awkward FE UX when using '...'
- Rule definition changing after save and potential pitfalls with TF

With option 4. generated routes stay compatible with external/remote AMs, FE
doesn't need to change as we allow mixed '...' and custom label groupBys, and
settings we save to db are the same ones requested.

In addition, it has the slight benefit of allowing us to hide the internal
implementation details of `alertname, grafana_folder` from the user in the
future, since we don't need to send them with every FE or TF request.

* Safer use of DefaultNotificationSettingsGroupBy

* Fix missed API tests

(cherry picked from commit 533bed6)
@grafana-delivery-bot grafana-delivery-bot bot requested review from a team, rwwiv, JacobsonMT, yuri-tceretian and grobinson-grafana and removed request for a team April 16, 2024 16:16
@grafana-delivery-bot grafana-delivery-bot bot added this to the 11.0.x milestone Apr 16, 2024
@JacobsonMT JacobsonMT modified the milestone: 11.0.x Apr 16, 2024
@JacobsonMT JacobsonMT merged commit 46353e6 into v11.0.x Apr 16, 2024
22 checks passed
@JacobsonMT JacobsonMT deleted the backport-86006-to-v11.0.x branch April 16, 2024 18:41
@fabrizio-grafana fabrizio-grafana modified the milestones: 11.0.x, 11.0.0 May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants