CloudMigrations: create snapshot for Alert Rules (#95404)
* CloudMigrations: create snapshot for Alert Rules * CloudMigrations: display Alert Rules in resource list summary
This commit is contained in:
@@ -36,6 +36,7 @@ var currentMigrationTypes = []cloudmigration.MigrateDataType{
|
||||
cloudmigration.NotificationTemplateType,
|
||||
cloudmigration.ContactPointType,
|
||||
cloudmigration.NotificationPolicyType,
|
||||
cloudmigration.AlertRuleType,
|
||||
}
|
||||
|
||||
func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.SignedInUser) (*cloudmigration.MigrateDataRequest, error) {
|
||||
@@ -90,10 +91,17 @@ func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.S
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Alerts: Alert Rules
|
||||
alertRules, err := s.getAlertRules(ctx, signedInUser)
|
||||
if err != nil {
|
||||
s.log.Error("Failed to get alert rules", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
migrationDataSlice := make(
|
||||
[]cloudmigration.MigrateDataRequestItem, 0,
|
||||
len(dataSources)+len(dashs)+len(folders)+len(libraryElements)+
|
||||
len(muteTimings)+len(notificationTemplates)+len(contactPoints),
|
||||
len(muteTimings)+len(notificationTemplates)+len(contactPoints)+len(alertRules),
|
||||
)
|
||||
|
||||
for _, ds := range dataSources {
|
||||
@@ -177,6 +185,15 @@ func (s *Service) getMigrationDataJSON(ctx context.Context, signedInUser *user.S
|
||||
})
|
||||
}
|
||||
|
||||
for _, alertRule := range alertRules {
|
||||
migrationDataSlice = append(migrationDataSlice, cloudmigration.MigrateDataRequestItem{
|
||||
Type: cloudmigration.AlertRuleType,
|
||||
RefID: alertRule.UID,
|
||||
Name: alertRule.Title,
|
||||
Data: alertRule,
|
||||
})
|
||||
}
|
||||
|
||||
// Obtain the names of parent elements for Dashboard and Folders data types
|
||||
parentNamesByType, err := s.getParentNames(ctx, signedInUser, dashs, folders, libraryElements)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user