Skip to content

Commit

Permalink
fix(observability-lib): getAlertRules by group name
Browse files Browse the repository at this point in the history
  • Loading branch information
Atrax1 committed Jan 23, 2025
1 parent bcaa629 commit 54d323c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions observability-lib/grafana/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,22 @@ func getAlertRules(grafanaClient *api.Client, dashboardUID *string, folderUID st
var alertsRule []alerting.Rule
var errGetAlertRules error

// check for alert rules by dashboard UID
if dashboardUID != nil {
alertsRule, errGetAlertRules = grafanaClient.GetAlertRulesByDashboardUID(*dashboardUID)
if errGetAlertRules != nil {
return nil, errGetAlertRules
}
} else {
if alertGroups != nil && len(alertGroups) > 0 {
for _, alertGroup := range alertGroups {
alertsRulePerGroup, errGetAlertRulesPerGroup := grafanaClient.GetAlertRulesByFolderUIDAndGroupName(folderUID, *alertGroup.Title)
if errGetAlertRulesPerGroup != nil {
return nil, errGetAlertRulesPerGroup
}
alertsRule = append(alertsRule, alertsRulePerGroup...)
}

// check for alert rules by folder UID and group name
if alertGroups != nil && len(alertGroups) > 0 {
for _, alertGroup := range alertGroups {
alertsRulePerGroup, errGetAlertRulesPerGroup := grafanaClient.GetAlertRulesByFolderUIDAndGroupName(folderUID, *alertGroup.Title)
if errGetAlertRulesPerGroup != nil {
return nil, errGetAlertRulesPerGroup
}
alertsRule = append(alertsRule, alertsRulePerGroup...)
}
}

Expand Down

0 comments on commit 54d323c

Please sign in to comment.