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

fix(observability-lib): getAlertRules by group name #1008

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading