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: Enable Unified Alerting for open source and enterprise #49834

Merged

Conversation

grobinson-grafana
Copy link
Contributor

@grobinson-grafana grobinson-grafana commented May 30, 2022

What this PR does / why we need it:

This pull request enables unified alerting for both open source and enterprise Grafana unless disabled in configuration.

It is enabled in the following situations:

  1. Neither old alerting or unified alerting have been configured (i.e. enabled is neither set for old alerting or unified alerting)
  2. Old alerting is enabled but unified alerting has not been configured

The following table shows the outcomes of different settings:

Alerting Unified Alerting Outcome
"" "" UA
"" true UA
"" false Legacy
true "" UA
true true Error
true false Legacy
false "" UA
false true UA
false false Disabled

@grafanabot
Copy link
Contributor

This commit enables Unified Alerting for open source and enterprise
unless disabled in configuration.
@grobinson-grafana grobinson-grafana force-pushed the grobinson/alerting-feature-ua-migrations-in-g9 branch from 397c8b4 to e0b7ef1 Compare May 30, 2022 14:48
Copy link
Contributor

@gotjosh gotjosh left a comment

Choose a reason for hiding this comment

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

LGTM

But please see my comments.

// At present an invalid value is considered the same as no value. This means that a
// spelling mistake in the string "false" could enable unified alerting rather
// than disable it. This issue can be found here
unifiedAlerting, err := section.Key("enabled").Bool()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we take the opportunity to fix this?

I think:

section.Key("enabled").MustBool(false)

Should be a safe bet to disable UA if there's ambiguity in the value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I spoke to Armand and we can fix this in a follow up due to the release going out tomorrow. It might require more careful changes and tests.

// At present an invalid value is considered the same as no value. This means that a
// spelling mistake in the string "false" could enable unified alerting rather
// than disable it. This issue can be found here
unifiedAlerting, err := section.Key("enabled").Bool()
if err != nil {
// TODO: Remove in Grafana v9
Copy link
Contributor

Choose a reason for hiding this comment

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

If we implement the above, I assume that's what this comment is referring to and we no longer need this block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The block would still be present but would change the if condition to section.HasKey("enabled"). There would be a separate if statement for when section.Key("enabled").Bool() returns an error.

}
// NOTE: If the enabled flag is still not defined, the final decision is made during migration (see sqlstore.migrations.ualert.CheckUnifiedAlertingEnabledByDefault).
cfg.Logger.Info("The state of unified alerting is still not defined. The decision will be made during as we run the database migrations")
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this partially true? IIRC were introduced a safety check to avoid losing data so I think there might be a case where a decision can be made at migration time - can you please double check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understand that this was required as before this change we had the following:

Alerting Unified Alerting alerts table has alerts Outcome
true "" true Legacy
true "" false UA
"" "" true Legacy
"" "" false UA

but now we changed this table to:

Alerting Unified Alerting alerts table has alerts Outcome
true "" true UA
true "" false UA
"" "" true UA
"" "" false UA

i.e. whether or not the database has alerts is irrelevant to the outcome and there is no longer a decision to be made at migration time.

@grobinson-grafana grobinson-grafana merged commit 3b7f871 into main May 30, 2022
@grobinson-grafana grobinson-grafana deleted the grobinson/alerting-feature-ua-migrations-in-g9 branch May 30, 2022 15:47
grafanabot pushed a commit that referenced this pull request May 30, 2022
)

This commit enables Unified Alerting for open source and enterprise unless disabled in configuration.

(cherry picked from commit 3b7f871)
armandgrillet pushed a commit that referenced this pull request May 30, 2022
) (#49845)

This commit enables Unified Alerting for open source and enterprise unless disabled in configuration.

(cherry picked from commit 3b7f871)

Co-authored-by: George Robinson <[email protected]>
@gotjosh
Copy link
Contributor

gotjosh commented May 30, 2022

@grobinson-grafana can you please add a changelog entry? sorry for not mentioning it early - I completely forgot 🙈

@cbernard-psee
Copy link

cbernard-psee commented Jun 3, 2022

@gotjosh : Does this PR allows to manage alerts as code with sidecars, like we used to operated using 8.2.7 release of Grafana OpenSource edition ? Unified Alert was a breaking change for this use case, it would be really great to recover this value and take the full benefit of "as code" way of working

@JohnnyQQQQ
Copy link
Member

@cbernard-psee not for now, this is tracked in #36153, the API for it is part of 9.0 but we didn't implement any provider yet (File provisioning, Terraform, etc.). Those providers are planned for 9.1 and 9.2.

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.

6 participants