Skip to content

Commit af63b06

Browse files
Check for missing_series_evals_to_resolve in the json
1 parent 0c8ed67 commit af63b06

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/resources/grafana/resource_alerting_rule_group.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,11 @@ func packAlertRule(r *models.ProvisionedAlertRule) (interface{}, error) {
542542
json["record"] = record
543543
}
544544

545-
// FIXME: open api needs to be a reference to the duration
546545
if r.KeepFiringFor != 0 {
547546
json["keep_firing_for"] = r.KeepFiringFor.String()
548547
}
549548

550-
if r.MissingSeriesEvalsToResolve > 1 {
549+
if r.MissingSeriesEvalsToResolve >= 1 {
551550
json["missing_series_evals_to_resolve"] = r.MissingSeriesEvalsToResolve
552551
}
553552

@@ -584,7 +583,13 @@ func unpackAlertRule(raw interface{}, groupName string, folderUID string, orgID
584583
return nil, err
585584
}
586585

587-
missingSeriesEvalsToResolve := int64(json["missing_series_evals_to_resolve"].(int))
586+
var missingSeriesEvalsToResolve int64
587+
if val, ok := json["missing_series_evals_to_resolve"]; ok && val != nil {
588+
intVal := val.(int)
589+
if intVal >= 1 {
590+
missingSeriesEvalsToResolve = int64(intVal)
591+
}
592+
}
588593

589594
// Check for conflicting fields before unpacking the rest of the rule.
590595
// This is a workaround due to the lack of support for ConflictsWith in Lists in the SDK.

0 commit comments

Comments
 (0)