Dispatch Rule
Provides a Application Real-Time Monitoring Service (ARMS) Alert Dispatch Rule resource. For information about Application Real-Time Monitoring Service (ARMS) Alert Dispatch Rule and how to use it, see What is Alert Dispatch_Rule.
NOTE: Available since v1.136.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const _default = new alicloud.arms.AlertContact("default", {
alertContactName: "example_value",
email: "example_value@aaa.com",
});
const defaultAlertContactGroup = new alicloud.arms.AlertContactGroup("default", {
alertContactGroupName: "example_value",
contactIds: [_default.id],
});
const defaultDispatchRule = new alicloud.arms.DispatchRule("default", {
dispatchRuleName: "example_value",
dispatchType: "CREATE_ALERT",
groupRules: [{
groupWaitTime: 5,
groupInterval: 15,
repeatInterval: 100,
groupingFields: ["alertname"],
}],
labelMatchExpressionGrids: [{
labelMatchExpressionGroups: [{
labelMatchExpressions: [{
key: "_aliyun_arms_involvedObject_kind",
value: "app",
operator: "eq",
}],
}],
}],
notifyRules: [{
notifyObjects: [
{
notifyObjectId: _default.id,
notifyType: "ARMS_CONTACT",
name: "example_value",
},
{
notifyObjectId: defaultAlertContactGroup.id,
notifyType: "ARMS_CONTACT_GROUP",
name: "example_value",
},
],
notifyChannels: [
"dingTalk",
"wechat",
],
}],
});import pulumi
import pulumi_alicloud as alicloud
default = alicloud.arms.AlertContact("default",
alert_contact_name="example_value",
email="example_value@aaa.com")
default_alert_contact_group = alicloud.arms.AlertContactGroup("default",
alert_contact_group_name="example_value",
contact_ids=[default.id])
default_dispatch_rule = alicloud.arms.DispatchRule("default",
dispatch_rule_name="example_value",
dispatch_type="CREATE_ALERT",
group_rules=[alicloud.arms.DispatchRuleGroupRuleArgs(
group_wait_time=5,
group_interval=15,
repeat_interval=100,
grouping_fields=["alertname"],
)],
label_match_expression_grids=[alicloud.arms.DispatchRuleLabelMatchExpressionGridArgs(
label_match_expression_groups=[alicloud.arms.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupArgs(
label_match_expressions=[alicloud.arms.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupLabelMatchExpressionArgs(
key="_aliyun_arms_involvedObject_kind",
value="app",
operator="eq",
)],
)],
)],
notify_rules=[alicloud.arms.DispatchRuleNotifyRuleArgs(
notify_objects=[
alicloud.arms.DispatchRuleNotifyRuleNotifyObjectArgs(
notify_object_id=default.id,
notify_type="ARMS_CONTACT",
name="example_value",
),
alicloud.arms.DispatchRuleNotifyRuleNotifyObjectArgs(
notify_object_id=default_alert_contact_group.id,
notify_type="ARMS_CONTACT_GROUP",
name="example_value",
),
],
notify_channels=[
"dingTalk",
"wechat",
],
)])using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var @default = new AliCloud.Arms.AlertContact("default", new()
{
AlertContactName = "example_value",
Email = "example_value@aaa.com",
});
var defaultAlertContactGroup = new AliCloud.Arms.AlertContactGroup("default", new()
{
AlertContactGroupName = "example_value",
ContactIds = new[]
{
@default.Id,
},
});
var defaultDispatchRule = new AliCloud.Arms.DispatchRule("default", new()
{
DispatchRuleName = "example_value",
DispatchType = "CREATE_ALERT",
GroupRules = new[]
{
new AliCloud.Arms.Inputs.DispatchRuleGroupRuleArgs
{
GroupWaitTime = 5,
GroupInterval = 15,
RepeatInterval = 100,
GroupingFields = new[]
{
"alertname",
},
},
},
LabelMatchExpressionGrids = new[]
{
new AliCloud.Arms.Inputs.DispatchRuleLabelMatchExpressionGridArgs
{
LabelMatchExpressionGroups = new[]
{
new AliCloud.Arms.Inputs.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupArgs
{
LabelMatchExpressions = new[]
{
new AliCloud.Arms.Inputs.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupLabelMatchExpressionArgs
{
Key = "_aliyun_arms_involvedObject_kind",
Value = "app",
Operator = "eq",
},
},
},
},
},
},
NotifyRules = new[]
{
new AliCloud.Arms.Inputs.DispatchRuleNotifyRuleArgs
{
NotifyObjects = new[]
{
new AliCloud.Arms.Inputs.DispatchRuleNotifyRuleNotifyObjectArgs
{
NotifyObjectId = @default.Id,
NotifyType = "ARMS_CONTACT",
Name = "example_value",
},
new AliCloud.Arms.Inputs.DispatchRuleNotifyRuleNotifyObjectArgs
{
NotifyObjectId = defaultAlertContactGroup.Id,
NotifyType = "ARMS_CONTACT_GROUP",
Name = "example_value",
},
},
NotifyChannels = new[]
{
"dingTalk",
"wechat",
},
},
},
});
});package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/arms"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := arms.NewAlertContact(ctx, "default", &arms.AlertContactArgs{
AlertContactName: pulumi.String("example_value"),
Email: pulumi.String("example_value@aaa.com"),
})
if err != nil {
return err
}
defaultAlertContactGroup, err := arms.NewAlertContactGroup(ctx, "default", &arms.AlertContactGroupArgs{
AlertContactGroupName: pulumi.String("example_value"),
ContactIds: pulumi.StringArray{
_default.ID(),
},
})
if err != nil {
return err
}
_, err = arms.NewDispatchRule(ctx, "default", &arms.DispatchRuleArgs{
DispatchRuleName: pulumi.String("example_value"),
DispatchType: pulumi.String("CREATE_ALERT"),
GroupRules: arms.DispatchRuleGroupRuleArray{
&arms.DispatchRuleGroupRuleArgs{
GroupWaitTime: pulumi.Int(5),
GroupInterval: pulumi.Int(15),
RepeatInterval: pulumi.Int(100),
GroupingFields: pulumi.StringArray{
pulumi.String("alertname"),
},
},
},
LabelMatchExpressionGrids: arms.DispatchRuleLabelMatchExpressionGridArray{
&arms.DispatchRuleLabelMatchExpressionGridArgs{
LabelMatchExpressionGroups: arms.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupArray{
&arms.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupArgs{
LabelMatchExpressions: arms.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupLabelMatchExpressionArray{
&arms.DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupLabelMatchExpressionArgs{
Key: pulumi.String("_aliyun_arms_involvedObject_kind"),
Value: pulumi.String("app"),
Operator: pulumi.String("eq"),
},
},
},
},
},
},
NotifyRules: arms.DispatchRuleNotifyRuleArray{
&arms.DispatchRuleNotifyRuleArgs{
NotifyObjects: arms.DispatchRuleNotifyRuleNotifyObjectArray{
&arms.DispatchRuleNotifyRuleNotifyObjectArgs{
NotifyObjectId: _default.ID(),
NotifyType: pulumi.String("ARMS_CONTACT"),
Name: pulumi.String("example_value"),
},
&arms.DispatchRuleNotifyRuleNotifyObjectArgs{
NotifyObjectId: defaultAlertContactGroup.ID(),
NotifyType: pulumi.String("ARMS_CONTACT_GROUP"),
Name: pulumi.String("example_value"),
},
},
NotifyChannels: pulumi.StringArray{
pulumi.String("dingTalk"),
pulumi.String("wechat"),
},
},
},
})
if err != nil {
return err
}
return nil
})
}package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.arms.AlertContact;
import com.pulumi.alicloud.arms.AlertContactArgs;
import com.pulumi.alicloud.arms.AlertContactGroup;
import com.pulumi.alicloud.arms.AlertContactGroupArgs;
import com.pulumi.alicloud.arms.DispatchRule;
import com.pulumi.alicloud.arms.DispatchRuleArgs;
import com.pulumi.alicloud.arms.inputs.DispatchRuleGroupRuleArgs;
import com.pulumi.alicloud.arms.inputs.DispatchRuleLabelMatchExpressionGridArgs;
import com.pulumi.alicloud.arms.inputs.DispatchRuleNotifyRuleArgs;
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 default_ = new AlertContact("default", AlertContactArgs.builder()
.alertContactName("example_value")
.email("example_value@aaa.com")
.build());
var defaultAlertContactGroup = new AlertContactGroup("defaultAlertContactGroup", AlertContactGroupArgs.builder()
.alertContactGroupName("example_value")
.contactIds(default_.id())
.build());
var defaultDispatchRule = new DispatchRule("defaultDispatchRule", DispatchRuleArgs.builder()
.dispatchRuleName("example_value")
.dispatchType("CREATE_ALERT")
.groupRules(DispatchRuleGroupRuleArgs.builder()
.groupWaitTime(5)
.groupInterval(15)
.repeatInterval(100)
.groupingFields("alertname")
.build())
.labelMatchExpressionGrids(DispatchRuleLabelMatchExpressionGridArgs.builder()
.labelMatchExpressionGroups(DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupArgs.builder()
.labelMatchExpressions(DispatchRuleLabelMatchExpressionGridLabelMatchExpressionGroupLabelMatchExpressionArgs.builder()
.key("_aliyun_arms_involvedObject_kind")
.value("app")
.operator("eq")
.build())
.build())
.build())
.notifyRules(DispatchRuleNotifyRuleArgs.builder()
.notifyObjects(
DispatchRuleNotifyRuleNotifyObjectArgs.builder()
.notifyObjectId(default_.id())
.notifyType("ARMS_CONTACT")
.name("example_value")
.build(),
DispatchRuleNotifyRuleNotifyObjectArgs.builder()
.notifyObjectId(defaultAlertContactGroup.id())
.notifyType("ARMS_CONTACT_GROUP")
.name("example_value")
.build())
.notifyChannels(
"dingTalk",
"wechat")
.build())
.build());
}
}resources:
default:
type: alicloud:arms:AlertContact
properties:
alertContactName: example_value
email: example_value@aaa.com
defaultAlertContactGroup:
type: alicloud:arms:AlertContactGroup
name: default
properties:
alertContactGroupName: example_value
contactIds:
- ${default.id}
defaultDispatchRule:
type: alicloud:arms:DispatchRule
name: default
properties:
dispatchRuleName: example_value
dispatchType: CREATE_ALERT
groupRules:
- groupWaitTime: 5
groupInterval: 15
repeatInterval: 100
groupingFields:
- alertname
labelMatchExpressionGrids:
- labelMatchExpressionGroups:
- labelMatchExpressions:
- key: _aliyun_arms_involvedObject_kind
value: app
operator: eq
notifyRules:
- notifyObjects:
- notifyObjectId: ${default.id}
notifyType: ARMS_CONTACT
name: example_value
- notifyObjectId: ${defaultAlertContactGroup.id}
notifyType: ARMS_CONTACT_GROUP
name: example_value
notifyChannels:
- dingTalk
- wechatImport
Application Real-Time Monitoring Service (ARMS) Alert Contact can be imported using the id, e.g.
$ pulumi import alicloud:arms/dispatchRule:DispatchRule example <id>Properties
The name of the dispatch policy.
The alert handling method. Valid values: CREATE_ALERT: generates an alert. DISCARD_ALERT: discards the alert event and generates no alert.
Sets the event group. See group_rules below. It will be ignored when dispatch_type = "DISCARD_ALERT".
Sets the dispatch rule. See label_match_expression_grid below.
Sets the notification rule. See notify_rules below. It will be ignored when dispatch_type = "DISCARD_ALERT".