mirror of
https://github.com/grafana/grafana.git
synced 2026-08-14 07:04:57 -05:00
Alerting: Guided legacy alerting upgrade dry-run (#80071)
This PR has two steps that together create a functional dry-run capability for the migration.
By enabling the feature flag alertingPreviewUpgrade when on legacy alerting it will:
a. Allow all Grafana Alerting background services except for the scheduler to start (multiorg alertmanager, state manager, routes, …).
b. Allow the UI to show Grafana Alerting pages alongside legacy ones (with appropriate in-app warnings that UA is not actually running).
c. Show a new “Alerting Upgrade” page and register associated /api/v1/upgrade endpoints that will allow the user to upgrade their organization live without restart and present a summary of the upgrade in a table.
This commit is contained in:
@@ -168,10 +168,17 @@ func (s *ServiceImpl) processAppPlugin(plugin pluginstore.Plugin, c *contextmode
|
||||
|
||||
func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *navtree.NavTreeRoot, plugin pluginstore.Plugin, appLink *navtree.NavLink) {
|
||||
// Handle moving apps into specific navtree sections
|
||||
var alertingNodes []*navtree.NavLink
|
||||
alertingNode := treeRoot.FindById(navtree.NavIDAlerting)
|
||||
if alertingNode == nil {
|
||||
// Search for legacy alerting node just in case
|
||||
alertingNode = treeRoot.FindById(navtree.NavIDAlertingLegacy)
|
||||
if alertingNode != nil {
|
||||
alertingNodes = append(alertingNodes, alertingNode)
|
||||
}
|
||||
if len(alertingNodes) == 0 || s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagAlertingPreviewUpgrade) {
|
||||
// If FlagAlertingPreviewUpgrade is enabled, we want to add both the legacy and new alerting nodes.
|
||||
alertingNode := treeRoot.FindById(navtree.NavIDAlertingLegacy)
|
||||
if alertingNode != nil {
|
||||
alertingNodes = append(alertingNodes, alertingNode)
|
||||
}
|
||||
}
|
||||
sectionID := navtree.NavIDApps
|
||||
|
||||
@@ -235,7 +242,7 @@ func (s *ServiceImpl) addPluginToSection(c *contextmodel.ReqContext, treeRoot *n
|
||||
})
|
||||
case navtree.NavIDAlertsAndIncidents:
|
||||
alertsAndIncidentsChildren := []*navtree.NavLink{}
|
||||
if alertingNode != nil {
|
||||
for _, alertingNode := range alertingNodes {
|
||||
alertsAndIncidentsChildren = append(alertsAndIncidentsChildren, alertingNode)
|
||||
treeRoot.RemoveSection(alertingNode)
|
||||
}
|
||||
|
||||
@@ -138,6 +138,11 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Prefere
|
||||
if legacyAlertSection := s.buildLegacyAlertNavLinks(c); legacyAlertSection != nil {
|
||||
treeRoot.AddSection(legacyAlertSection)
|
||||
}
|
||||
if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagAlertingPreviewUpgrade) && !uaIsDisabledForOrg {
|
||||
if alertingSection := s.buildAlertNavLinks(c); alertingSection != nil {
|
||||
treeRoot.AddSection(alertingSection)
|
||||
}
|
||||
}
|
||||
} else if uaVisibleForOrg {
|
||||
if alertingSection := s.buildAlertNavLinks(c); alertingSection != nil {
|
||||
treeRoot.AddSection(alertingSection)
|
||||
@@ -404,6 +409,14 @@ func (s *ServiceImpl) buildLegacyAlertNavLinks(c *contextmodel.ReqContext) *navt
|
||||
})
|
||||
}
|
||||
|
||||
if s.features.IsEnabled(c.Req.Context(), featuremgmt.FlagAlertingPreviewUpgrade) && c.HasRole(org.RoleAdmin) {
|
||||
alertChildNavs = append(alertChildNavs, &navtree.NavLink{
|
||||
Text: "Upgrade Alerting", Id: "alerting-upgrade", Url: s.cfg.AppSubURL + "/alerting-legacy/upgrade",
|
||||
SubTitle: "Upgrade your existing legacy alerts and notification channels to the new Grafana Alerting",
|
||||
Icon: "cog",
|
||||
})
|
||||
}
|
||||
|
||||
var alertNav = navtree.NavLink{
|
||||
Text: "Alerting",
|
||||
SubTitle: "Learn about problems in your systems moments after they occur",
|
||||
|
||||
Reference in New Issue
Block a user