Alert Rule
The alert rule resource. Azure REST API version: 2016-03-01. Prior API version in Azure Native 1.x: 2016-03-01.
Example Usage
Create or update an alert rule
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AzureNative = Pulumi.AzureNative;
return await Deployment.RunAsync(() =>
{
var alertRule = new AzureNative.Insights.AlertRule("alertRule", new()
{
Actions = new[] {},
Condition = new AzureNative.Insights.Inputs.ThresholdRuleConditionArgs
{
DataSource = new AzureNative.Insights.Inputs.RuleMetricDataSourceArgs
{
MetricName = "Requests",
OdataType = "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
ResourceUri = "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest",
},
OdataType = "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
Operator = AzureNative.Insights.ConditionOperator.GreaterThan,
Threshold = 3,
TimeAggregation = AzureNative.Insights.TimeAggregationOperator.Total,
WindowSize = "PT5M",
},
Description = "Pura Vida",
IsEnabled = true,
Location = "West US",
Name = "chiricutin",
ResourceGroupName = "Rac46PostSwapRG",
RuleName = "chiricutin",
Tags = null,
});
});
Content copied to clipboard
package main
import (
"github.com/pulumi/pulumi-azure-native-sdk/insights/v2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := insights.NewAlertRule(ctx, "alertRule", &insights.AlertRuleArgs{
Actions: pulumi.AnyArray{},
Condition: insights.ThresholdRuleCondition{
DataSource: insights.RuleMetricDataSource{
MetricName: "Requests",
OdataType: "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource",
ResourceUri: "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest",
},
OdataType: "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition",
Operator: insights.ConditionOperatorGreaterThan,
Threshold: 3,
TimeAggregation: insights.TimeAggregationOperatorTotal,
WindowSize: "PT5M",
},
Description: pulumi.String("Pura Vida"),
IsEnabled: pulumi.Bool(true),
Location: pulumi.String("West US"),
Name: pulumi.String("chiricutin"),
ResourceGroupName: pulumi.String("Rac46PostSwapRG"),
RuleName: pulumi.String("chiricutin"),
Tags: nil,
})
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.insights.AlertRule;
import com.pulumi.azurenative.insights.AlertRuleArgs;
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 alertRule = new AlertRule("alertRule", AlertRuleArgs.builder()
.actions()
.condition(Map.ofEntries(
Map.entry("dataSource", Map.ofEntries(
Map.entry("metricName", "Requests"),
Map.entry("odataType", "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource"),
Map.entry("resourceUri", "/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest")
)),
Map.entry("odataType", "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition"),
Map.entry("operator", "GreaterThan"),
Map.entry("threshold", 3),
Map.entry("timeAggregation", "Total"),
Map.entry("windowSize", "PT5M")
))
.description("Pura Vida")
.isEnabled(true)
.location("West US")
.name("chiricutin")
.resourceGroupName("Rac46PostSwapRG")
.ruleName("chiricutin")
.tags()
.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:insights:AlertRule chiricutin /subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}
Content copied to clipboard