Alerting: Remove ngalert feature toggle and introduce two new settings for enabling Grafana 8 alerts and disabling them for specific organisations (#38746) (#39793)
* Remove `ngalert` feature toggle
* Update frontend
Remove all references of ngalert feature toggle
* Update docs
* Disable unified alerting for specific orgs
* Add backend tests
* Apply suggestions from code review
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
* Disabled unified alerting by default
* Ensure backward compatibility with old ngalert feature toggle
* Apply suggestions from code review
Co-authored-by: gotjosh <josue@grafana.com>
(cherry picked from commit 012d4f0905)
This commit is contained in:
@@ -49,10 +49,8 @@ func AddDashAlertMigration(mg *migrator.Migrator) {
|
||||
|
||||
_, migrationRun := logs[migTitle]
|
||||
|
||||
ngEnabled := mg.Cfg.IsNgAlertEnabled()
|
||||
|
||||
switch {
|
||||
case ngEnabled && !migrationRun:
|
||||
case mg.Cfg.UnifiedAlerting.Enabled && !migrationRun:
|
||||
// Remove the migration entry that removes all unified alerting data. This is so when the feature
|
||||
// flag is removed in future the "remove unified alerting data" migration will be run again.
|
||||
mg.AddMigration(fmt.Sprintf(clearMigrationEntryTitle, rmMigTitle), &clearMigrationEntry{
|
||||
@@ -67,7 +65,7 @@ func AddDashAlertMigration(mg *migrator.Migrator) {
|
||||
portedChannelGroupsPerOrg: make(map[int64]map[string]string),
|
||||
silences: make(map[int64][]*pb.MeshSilence),
|
||||
})
|
||||
case !ngEnabled && migrationRun:
|
||||
case !mg.Cfg.UnifiedAlerting.Enabled && migrationRun:
|
||||
// Remove the migration entry that creates unified alerting data. This is so when the feature
|
||||
// flag is enabled in the future the migration "move dashboard alerts to unified alerting" will be run again.
|
||||
mg.AddMigration(fmt.Sprintf(clearMigrationEntryTitle, migTitle), &clearMigrationEntry{
|
||||
@@ -92,7 +90,7 @@ func RerunDashAlertMigration(mg *migrator.Migrator) {
|
||||
cloneMigTitle := fmt.Sprintf("clone %s", migTitle)
|
||||
|
||||
_, migrationRun := logs[cloneMigTitle]
|
||||
ngEnabled := mg.Cfg.IsNgAlertEnabled()
|
||||
ngEnabled := mg.Cfg.UnifiedAlerting.Enabled
|
||||
|
||||
switch {
|
||||
case ngEnabled && !migrationRun:
|
||||
|
||||
@@ -41,7 +41,7 @@ func GetOrgQuotaByTarget(query *models.GetOrgQuotaByTargetQuery) error {
|
||||
}
|
||||
|
||||
var used int64
|
||||
if query.Target != alertRuleTarget || query.IsNgAlertEnabled {
|
||||
if query.Target != alertRuleTarget || query.UnifiedAlertingEnabled {
|
||||
// get quota used.
|
||||
rawSQL := fmt.Sprintf("SELECT COUNT(*) AS count FROM %s WHERE org_id=?",
|
||||
dialect.Quote(query.Target))
|
||||
@@ -94,7 +94,7 @@ func GetOrgQuotas(query *models.GetOrgQuotasQuery) error {
|
||||
result := make([]*models.OrgQuotaDTO, len(quotas))
|
||||
for i, q := range quotas {
|
||||
var used int64
|
||||
if q.Target != alertRuleTarget || query.IsNgAlertEnabled {
|
||||
if q.Target != alertRuleTarget || query.UnifiedAlertingEnabled {
|
||||
// get quota used.
|
||||
rawSQL := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(q.Target))
|
||||
resp := make([]*targetCount, 0)
|
||||
@@ -158,7 +158,7 @@ func GetUserQuotaByTarget(query *models.GetUserQuotaByTargetQuery) error {
|
||||
}
|
||||
|
||||
var used int64
|
||||
if query.Target != alertRuleTarget || query.IsNgAlertEnabled {
|
||||
if query.Target != alertRuleTarget || query.UnifiedAlertingEnabled {
|
||||
// get quota used.
|
||||
rawSQL := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(query.Target))
|
||||
resp := make([]*targetCount, 0)
|
||||
@@ -205,7 +205,7 @@ func GetUserQuotas(query *models.GetUserQuotasQuery) error {
|
||||
result := make([]*models.UserQuotaDTO, len(quotas))
|
||||
for i, q := range quotas {
|
||||
var used int64
|
||||
if q.Target != alertRuleTarget || query.IsNgAlertEnabled {
|
||||
if q.Target != alertRuleTarget || query.UnifiedAlertingEnabled {
|
||||
// get quota used.
|
||||
rawSQL := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(q.Target))
|
||||
resp := make([]*targetCount, 0)
|
||||
@@ -258,7 +258,7 @@ func UpdateUserQuota(cmd *models.UpdateUserQuotaCmd) error {
|
||||
|
||||
func GetGlobalQuotaByTarget(query *models.GetGlobalQuotaByTargetQuery) error {
|
||||
var used int64
|
||||
if query.Target != alertRuleTarget || query.IsNgAlertEnabled {
|
||||
if query.Target != alertRuleTarget || query.UnifiedAlertingEnabled {
|
||||
// get quota used.
|
||||
rawSQL := fmt.Sprintf("SELECT COUNT(*) AS count FROM %s",
|
||||
dialect.Quote(query.Target))
|
||||
|
||||
Reference in New Issue
Block a user