Smart Detector Alert Rule
The alert rule information Uses Azure REST API version 2021-04-01. In version 2.x of the Azure Native provider, it used API version 2021-04-01. Other available API versions: 2019-06-01. These can be accessed by generating a local SDK package using the CLI command pulumi package add azure-native alertsmanagement [ApiVersion]
. See the ../../../version-guide/#accessing-any-api-version-via-local-packages for details.
Example Usage
Create or update a Smart Detector alert rule
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var smartDetectorAlertRule = new AzureNative.AlertsManagement.SmartDetectorAlertRule("smartDetectorAlertRule", new()
{
ActionGroups = new AzureNative.AlertsManagement.Inputs.ActionGroupsInformationArgs
{
CustomEmailSubject = "My custom email subject",
CustomWebhookPayload = "{\"AlertRuleName\":\"#alertrulename\"}",
GroupIds = new[]
{
"/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup",
},
},
AlertRuleName = "MyAlertRule",
Description = "Sample smart detector alert rule description",
Detector = new AzureNative.AlertsManagement.Inputs.DetectorArgs
{
Id = "VMMemoryLeak",
},
Frequency = "PT5M",
ResourceGroupName = "MyAlertRules",
Scope = new[]
{
"/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1",
},
Severity = AzureNative.AlertsManagement.Severity.Sev3,
State = AzureNative.AlertsManagement.AlertRuleState.Enabled,
Throttling = new AzureNative.AlertsManagement.Inputs.ThrottlingInformationArgs
{
Duration = "PT20M",
},
});
});
Content copied to clipboard
package main
import (
alertsmanagement "github.com/pulumi/pulumi-azure-native-sdk/alertsmanagement/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := alertsmanagement.NewSmartDetectorAlertRule(ctx, "smartDetectorAlertRule", &alertsmanagement.SmartDetectorAlertRuleArgs{
ActionGroups: &alertsmanagement.ActionGroupsInformationArgs{
CustomEmailSubject: pulumi.String("My custom email subject"),
CustomWebhookPayload: pulumi.String("{\"AlertRuleName\":\"#alertrulename\"}"),
GroupIds: pulumi.StringArray{
pulumi.String("/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup"),
},
},
AlertRuleName: pulumi.String("MyAlertRule"),
Description: pulumi.String("Sample smart detector alert rule description"),
Detector: &alertsmanagement.DetectorArgs{
Id: pulumi.String("VMMemoryLeak"),
},
Frequency: pulumi.String("PT5M"),
ResourceGroupName: pulumi.String("MyAlertRules"),
Scope: pulumi.StringArray{
pulumi.String("/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1"),
},
Severity: pulumi.String(alertsmanagement.SeveritySev3),
State: pulumi.String(alertsmanagement.AlertRuleStateEnabled),
Throttling: &alertsmanagement.ThrottlingInformationArgs{
Duration: pulumi.String("PT20M"),
},
})
if err != nil {
return err
}
return nil
})
}
Content copied to clipboard
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azurenative.alertsmanagement.SmartDetectorAlertRule;
import com.pulumi.azurenative.alertsmanagement.SmartDetectorAlertRuleArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.ActionGroupsInformationArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.DetectorArgs;
import com.pulumi.azurenative.alertsmanagement.inputs.ThrottlingInformationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var smartDetectorAlertRule = new SmartDetectorAlertRule("smartDetectorAlertRule", SmartDetectorAlertRuleArgs.builder()
.actionGroups(ActionGroupsInformationArgs.builder()
.customEmailSubject("My custom email subject")
.customWebhookPayload("{\"AlertRuleName\":\"#alertrulename\"}")
.groupIds("/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourcegroups/actionGroups/providers/microsoft.insights/actiongroups/MyActionGroup")
.build())
.alertRuleName("MyAlertRule")
.description("Sample smart detector alert rule description")
.detector(DetectorArgs.builder()
.id("VMMemoryLeak")
.build())
.frequency("PT5M")
.resourceGroupName("MyAlertRules")
.scope("/subscriptions/b368ca2f-e298-46b7-b0ab-012281956afa/resourceGroups/MyVms/providers/Microsoft.Compute/virtualMachines/vm1")
.severity("Sev3")
.state("Enabled")
.throttling(ThrottlingInformationArgs.builder()
.duration("PT20M")
.build())
.build());
}
}
Content copied to clipboard
Import
An existing resource can be imported using its type token, name, and identifier, e.g.
$ pulumi import azure-native:alertsmanagement:SmartDetectorAlertRule MyAlertRule /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}
Content copied to clipboard
Properties
Link copied to clipboard
The alert rule actions.
Link copied to clipboard
The Azure API version of the resource.
Link copied to clipboard
The alert rule description.
Link copied to clipboard
The alert rule's detector.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
The alert rule throttling information.