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

Support for auto-mitigate for Monitor scheduled query rules alerts #13036 #13213

Merged
merged 18 commits into from
Sep 15, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func resourceMonitorScheduledQueryRulesAlert() *pluginsdk.Resource {
"throttling": {
Type: pluginsdk.TypeInt,
Optional: true,
Default: nil,
cloutier marked this conversation as resolved.
Show resolved Hide resolved
ValidateFunc: validation.IntBetween(0, 10000),
ConflictsWith: []string{"auto_mitigation_enabled"},
},
Expand Down Expand Up @@ -395,17 +396,20 @@ func expandMonitorScheduledQueryRulesAlertingAction(d *pluginsdk.ResourceData) *
alertAction := expandMonitorScheduledQueryRulesAlertAction(alertActionRaw)
severityRaw := d.Get("severity").(int)
severity := strconv.Itoa(severityRaw)
throttling := d.Get("throttling").(int)
throttling, throttlingOk := d.GetOk("throttling")
cloutier marked this conversation as resolved.
Show resolved Hide resolved

triggerRaw := d.Get("trigger").([]interface{})
trigger := expandMonitorScheduledQueryRulesAlertTrigger(triggerRaw)

action := insights.AlertingAction{
AznsAction: alertAction,
Severity: insights.AlertSeverity(severity),
ThrottlingInMin: utils.Int32(int32(throttling)),
Trigger: trigger,
OdataType: insights.OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction,
AznsAction: alertAction,
Severity: insights.AlertSeverity(severity),
Trigger: trigger,
OdataType: insights.OdataTypeBasicActionOdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction,
}

if throttlingOk {
cloutier marked this conversation as resolved.
Show resolved Hide resolved
action.ThrottlingInMin = utils.Int32(int32(throttling.(int)))
}

return &action
Expand Down