aws.cloudwatch.MetricAlarm
Explore with Pulumi AI
Provides a CloudWatch Metric Alarm resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const foobar = new aws.cloudwatch.MetricAlarm("foobar", {
name: "test-foobar5",
comparisonOperator: "GreaterThanOrEqualToThreshold",
evaluationPeriods: 2,
metricName: "CPUUtilization",
namespace: "AWS/EC2",
period: 120,
statistic: "Average",
threshold: 80,
alarmDescription: "This metric monitors ec2 cpu utilization",
insufficientDataActions: [],
});
import pulumi
import pulumi_aws as aws
foobar = aws.cloudwatch.MetricAlarm("foobar",
name="test-foobar5",
comparison_operator="GreaterThanOrEqualToThreshold",
evaluation_periods=2,
metric_name="CPUUtilization",
namespace="AWS/EC2",
period=120,
statistic="Average",
threshold=80,
alarm_description="This metric monitors ec2 cpu utilization",
insufficient_data_actions=[])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudwatch.NewMetricAlarm(ctx, "foobar", &cloudwatch.MetricAlarmArgs{
Name: pulumi.String("test-foobar5"),
ComparisonOperator: pulumi.String("GreaterThanOrEqualToThreshold"),
EvaluationPeriods: pulumi.Int(2),
MetricName: pulumi.String("CPUUtilization"),
Namespace: pulumi.String("AWS/EC2"),
Period: pulumi.Int(120),
Statistic: pulumi.String("Average"),
Threshold: pulumi.Float64(80),
AlarmDescription: pulumi.String("This metric monitors ec2 cpu utilization"),
InsufficientDataActions: pulumi.Array{},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var foobar = new Aws.CloudWatch.MetricAlarm("foobar", new()
{
Name = "test-foobar5",
ComparisonOperator = "GreaterThanOrEqualToThreshold",
EvaluationPeriods = 2,
MetricName = "CPUUtilization",
Namespace = "AWS/EC2",
Period = 120,
Statistic = "Average",
Threshold = 80,
AlarmDescription = "This metric monitors ec2 cpu utilization",
InsufficientDataActions = new[] {},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.MetricAlarm;
import com.pulumi.aws.cloudwatch.MetricAlarmArgs;
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 foobar = new MetricAlarm("foobar", MetricAlarmArgs.builder()
.name("test-foobar5")
.comparisonOperator("GreaterThanOrEqualToThreshold")
.evaluationPeriods(2)
.metricName("CPUUtilization")
.namespace("AWS/EC2")
.period(120)
.statistic("Average")
.threshold(80)
.alarmDescription("This metric monitors ec2 cpu utilization")
.insufficientDataActions()
.build());
}
}
resources:
foobar:
type: aws:cloudwatch:MetricAlarm
properties:
name: test-foobar5
comparisonOperator: GreaterThanOrEqualToThreshold
evaluationPeriods: 2
metricName: CPUUtilization
namespace: AWS/EC2
period: 120
statistic: Average
threshold: 80
alarmDescription: This metric monitors ec2 cpu utilization
insufficientDataActions: []
Example in Conjunction with Scaling Policies
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bat = new aws.autoscaling.Policy("bat", {
name: "foobar3-test",
scalingAdjustment: 4,
adjustmentType: "ChangeInCapacity",
cooldown: 300,
autoscalingGroupName: bar.name,
});
const batMetricAlarm = new aws.cloudwatch.MetricAlarm("bat", {
name: "test-foobar5",
comparisonOperator: "GreaterThanOrEqualToThreshold",
evaluationPeriods: 2,
metricName: "CPUUtilization",
namespace: "AWS/EC2",
period: 120,
statistic: "Average",
threshold: 80,
dimensions: {
AutoScalingGroupName: bar.name,
},
alarmDescription: "This metric monitors ec2 cpu utilization",
alarmActions: [bat.arn],
});
import pulumi
import pulumi_aws as aws
bat = aws.autoscaling.Policy("bat",
name="foobar3-test",
scaling_adjustment=4,
adjustment_type="ChangeInCapacity",
cooldown=300,
autoscaling_group_name=bar["name"])
bat_metric_alarm = aws.cloudwatch.MetricAlarm("bat",
name="test-foobar5",
comparison_operator="GreaterThanOrEqualToThreshold",
evaluation_periods=2,
metric_name="CPUUtilization",
namespace="AWS/EC2",
period=120,
statistic="Average",
threshold=80,
dimensions={
"AutoScalingGroupName": bar["name"],
},
alarm_description="This metric monitors ec2 cpu utilization",
alarm_actions=[bat.arn])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/autoscaling"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bat, err := autoscaling.NewPolicy(ctx, "bat", &autoscaling.PolicyArgs{
Name: pulumi.String("foobar3-test"),
ScalingAdjustment: pulumi.Int(4),
AdjustmentType: pulumi.String("ChangeInCapacity"),
Cooldown: pulumi.Int(300),
AutoscalingGroupName: pulumi.Any(bar.Name),
})
if err != nil {
return err
}
_, err = cloudwatch.NewMetricAlarm(ctx, "bat", &cloudwatch.MetricAlarmArgs{
Name: pulumi.String("test-foobar5"),
ComparisonOperator: pulumi.String("GreaterThanOrEqualToThreshold"),
EvaluationPeriods: pulumi.Int(2),
MetricName: pulumi.String("CPUUtilization"),
Namespace: pulumi.String("AWS/EC2"),
Period: pulumi.Int(120),
Statistic: pulumi.String("Average"),
Threshold: pulumi.Float64(80),
Dimensions: pulumi.StringMap{
"AutoScalingGroupName": pulumi.Any(bar.Name),
},
AlarmDescription: pulumi.String("This metric monitors ec2 cpu utilization"),
AlarmActions: pulumi.Array{
bat.Arn,
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var bat = new Aws.AutoScaling.Policy("bat", new()
{
Name = "foobar3-test",
ScalingAdjustment = 4,
AdjustmentType = "ChangeInCapacity",
Cooldown = 300,
AutoscalingGroupName = bar.Name,
});
var batMetricAlarm = new Aws.CloudWatch.MetricAlarm("bat", new()
{
Name = "test-foobar5",
ComparisonOperator = "GreaterThanOrEqualToThreshold",
EvaluationPeriods = 2,
MetricName = "CPUUtilization",
Namespace = "AWS/EC2",
Period = 120,
Statistic = "Average",
Threshold = 80,
Dimensions =
{
{ "AutoScalingGroupName", bar.Name },
},
AlarmDescription = "This metric monitors ec2 cpu utilization",
AlarmActions = new[]
{
bat.Arn,
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.autoscaling.Policy;
import com.pulumi.aws.autoscaling.PolicyArgs;
import com.pulumi.aws.cloudwatch.MetricAlarm;
import com.pulumi.aws.cloudwatch.MetricAlarmArgs;
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 bat = new Policy("bat", PolicyArgs.builder()
.name("foobar3-test")
.scalingAdjustment(4)
.adjustmentType("ChangeInCapacity")
.cooldown(300)
.autoscalingGroupName(bar.name())
.build());
var batMetricAlarm = new MetricAlarm("batMetricAlarm", MetricAlarmArgs.builder()
.name("test-foobar5")
.comparisonOperator("GreaterThanOrEqualToThreshold")
.evaluationPeriods(2)
.metricName("CPUUtilization")
.namespace("AWS/EC2")
.period(120)
.statistic("Average")
.threshold(80)
.dimensions(Map.of("AutoScalingGroupName", bar.name()))
.alarmDescription("This metric monitors ec2 cpu utilization")
.alarmActions(bat.arn())
.build());
}
}
resources:
bat:
type: aws:autoscaling:Policy
properties:
name: foobar3-test
scalingAdjustment: 4
adjustmentType: ChangeInCapacity
cooldown: 300
autoscalingGroupName: ${bar.name}
batMetricAlarm:
type: aws:cloudwatch:MetricAlarm
name: bat
properties:
name: test-foobar5
comparisonOperator: GreaterThanOrEqualToThreshold
evaluationPeriods: 2
metricName: CPUUtilization
namespace: AWS/EC2
period: 120
statistic: Average
threshold: 80
dimensions:
AutoScalingGroupName: ${bar.name}
alarmDescription: This metric monitors ec2 cpu utilization
alarmActions:
- ${bat.arn}
Example with an Expression
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const foobar = new aws.cloudwatch.MetricAlarm("foobar", {
name: "test-foobar",
comparisonOperator: "GreaterThanOrEqualToThreshold",
evaluationPeriods: 2,
threshold: 10,
alarmDescription: "Request error rate has exceeded 10%",
insufficientDataActions: [],
metricQueries: [
{
id: "e1",
expression: "m2/m1*100",
label: "Error Rate",
returnData: true,
},
{
id: "m1",
metric: {
metricName: "RequestCount",
namespace: "AWS/ApplicationELB",
period: 120,
stat: "Sum",
unit: "Count",
dimensions: {
LoadBalancer: "app/web",
},
},
},
{
id: "m2",
metric: {
metricName: "HTTPCode_ELB_5XX_Count",
namespace: "AWS/ApplicationELB",
period: 120,
stat: "Sum",
unit: "Count",
dimensions: {
LoadBalancer: "app/web",
},
},
},
],
});
import pulumi
import pulumi_aws as aws
foobar = aws.cloudwatch.MetricAlarm("foobar",
name="test-foobar",
comparison_operator="GreaterThanOrEqualToThreshold",
evaluation_periods=2,
threshold=10,
alarm_description="Request error rate has exceeded 10%",
insufficient_data_actions=[],
metric_queries=[
{
"id": "e1",
"expression": "m2/m1*100",
"label": "Error Rate",
"return_data": True,
},
{
"id": "m1",
"metric": {
"metric_name": "RequestCount",
"namespace": "AWS/ApplicationELB",
"period": 120,
"stat": "Sum",
"unit": "Count",
"dimensions": {
"LoadBalancer": "app/web",
},
},
},
{
"id": "m2",
"metric": {
"metric_name": "HTTPCode_ELB_5XX_Count",
"namespace": "AWS/ApplicationELB",
"period": 120,
"stat": "Sum",
"unit": "Count",
"dimensions": {
"LoadBalancer": "app/web",
},
},
},
])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudwatch.NewMetricAlarm(ctx, "foobar", &cloudwatch.MetricAlarmArgs{
Name: pulumi.String("test-foobar"),
ComparisonOperator: pulumi.String("GreaterThanOrEqualToThreshold"),
EvaluationPeriods: pulumi.Int(2),
Threshold: pulumi.Float64(10),
AlarmDescription: pulumi.String("Request error rate has exceeded 10%"),
InsufficientDataActions: pulumi.Array{},
MetricQueries: cloudwatch.MetricAlarmMetricQueryArray{
&cloudwatch.MetricAlarmMetricQueryArgs{
Id: pulumi.String("e1"),
Expression: pulumi.String("m2/m1*100"),
Label: pulumi.String("Error Rate"),
ReturnData: pulumi.Bool(true),
},
&cloudwatch.MetricAlarmMetricQueryArgs{
Id: pulumi.String("m1"),
Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
MetricName: pulumi.String("RequestCount"),
Namespace: pulumi.String("AWS/ApplicationELB"),
Period: pulumi.Int(120),
Stat: pulumi.String("Sum"),
Unit: pulumi.String("Count"),
Dimensions: pulumi.StringMap{
"LoadBalancer": pulumi.String("app/web"),
},
},
},
&cloudwatch.MetricAlarmMetricQueryArgs{
Id: pulumi.String("m2"),
Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
MetricName: pulumi.String("HTTPCode_ELB_5XX_Count"),
Namespace: pulumi.String("AWS/ApplicationELB"),
Period: pulumi.Int(120),
Stat: pulumi.String("Sum"),
Unit: pulumi.String("Count"),
Dimensions: pulumi.StringMap{
"LoadBalancer": pulumi.String("app/web"),
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var foobar = new Aws.CloudWatch.MetricAlarm("foobar", new()
{
Name = "test-foobar",
ComparisonOperator = "GreaterThanOrEqualToThreshold",
EvaluationPeriods = 2,
Threshold = 10,
AlarmDescription = "Request error rate has exceeded 10%",
InsufficientDataActions = new[] {},
MetricQueries = new[]
{
new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
{
Id = "e1",
Expression = "m2/m1*100",
Label = "Error Rate",
ReturnData = true,
},
new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
{
Id = "m1",
Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
{
MetricName = "RequestCount",
Namespace = "AWS/ApplicationELB",
Period = 120,
Stat = "Sum",
Unit = "Count",
Dimensions =
{
{ "LoadBalancer", "app/web" },
},
},
},
new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
{
Id = "m2",
Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
{
MetricName = "HTTPCode_ELB_5XX_Count",
Namespace = "AWS/ApplicationELB",
Period = 120,
Stat = "Sum",
Unit = "Count",
Dimensions =
{
{ "LoadBalancer", "app/web" },
},
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.MetricAlarm;
import com.pulumi.aws.cloudwatch.MetricAlarmArgs;
import com.pulumi.aws.cloudwatch.inputs.MetricAlarmMetricQueryArgs;
import com.pulumi.aws.cloudwatch.inputs.MetricAlarmMetricQueryMetricArgs;
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 foobar = new MetricAlarm("foobar", MetricAlarmArgs.builder()
.name("test-foobar")
.comparisonOperator("GreaterThanOrEqualToThreshold")
.evaluationPeriods(2)
.threshold(10)
.alarmDescription("Request error rate has exceeded 10%")
.insufficientDataActions()
.metricQueries(
MetricAlarmMetricQueryArgs.builder()
.id("e1")
.expression("m2/m1*100")
.label("Error Rate")
.returnData("true")
.build(),
MetricAlarmMetricQueryArgs.builder()
.id("m1")
.metric(MetricAlarmMetricQueryMetricArgs.builder()
.metricName("RequestCount")
.namespace("AWS/ApplicationELB")
.period(120)
.stat("Sum")
.unit("Count")
.dimensions(Map.of("LoadBalancer", "app/web"))
.build())
.build(),
MetricAlarmMetricQueryArgs.builder()
.id("m2")
.metric(MetricAlarmMetricQueryMetricArgs.builder()
.metricName("HTTPCode_ELB_5XX_Count")
.namespace("AWS/ApplicationELB")
.period(120)
.stat("Sum")
.unit("Count")
.dimensions(Map.of("LoadBalancer", "app/web"))
.build())
.build())
.build());
}
}
resources:
foobar:
type: aws:cloudwatch:MetricAlarm
properties:
name: test-foobar
comparisonOperator: GreaterThanOrEqualToThreshold
evaluationPeriods: 2
threshold: 10
alarmDescription: Request error rate has exceeded 10%
insufficientDataActions: []
metricQueries:
- id: e1
expression: m2/m1*100
label: Error Rate
returnData: 'true'
- id: m1
metric:
metricName: RequestCount
namespace: AWS/ApplicationELB
period: 120
stat: Sum
unit: Count
dimensions:
LoadBalancer: app/web
- id: m2
metric:
metricName: HTTPCode_ELB_5XX_Count
namespace: AWS/ApplicationELB
period: 120
stat: Sum
unit: Count
dimensions:
LoadBalancer: app/web
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const xxAnomalyDetection = new aws.cloudwatch.MetricAlarm("xx_anomaly_detection", {
name: "test-foobar",
comparisonOperator: "GreaterThanUpperThreshold",
evaluationPeriods: 2,
thresholdMetricId: "e1",
alarmDescription: "This metric monitors ec2 cpu utilization",
insufficientDataActions: [],
metricQueries: [
{
id: "e1",
expression: "ANOMALY_DETECTION_BAND(m1)",
label: "CPUUtilization (Expected)",
returnData: true,
},
{
id: "m1",
returnData: true,
metric: {
metricName: "CPUUtilization",
namespace: "AWS/EC2",
period: 120,
stat: "Average",
unit: "Count",
dimensions: {
InstanceId: "i-abc123",
},
},
},
],
});
import pulumi
import pulumi_aws as aws
xx_anomaly_detection = aws.cloudwatch.MetricAlarm("xx_anomaly_detection",
name="test-foobar",
comparison_operator="GreaterThanUpperThreshold",
evaluation_periods=2,
threshold_metric_id="e1",
alarm_description="This metric monitors ec2 cpu utilization",
insufficient_data_actions=[],
metric_queries=[
{
"id": "e1",
"expression": "ANOMALY_DETECTION_BAND(m1)",
"label": "CPUUtilization (Expected)",
"return_data": True,
},
{
"id": "m1",
"return_data": True,
"metric": {
"metric_name": "CPUUtilization",
"namespace": "AWS/EC2",
"period": 120,
"stat": "Average",
"unit": "Count",
"dimensions": {
"InstanceId": "i-abc123",
},
},
},
])
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudwatch.NewMetricAlarm(ctx, "xx_anomaly_detection", &cloudwatch.MetricAlarmArgs{
Name: pulumi.String("test-foobar"),
ComparisonOperator: pulumi.String("GreaterThanUpperThreshold"),
EvaluationPeriods: pulumi.Int(2),
ThresholdMetricId: pulumi.String("e1"),
AlarmDescription: pulumi.String("This metric monitors ec2 cpu utilization"),
InsufficientDataActions: pulumi.Array{},
MetricQueries: cloudwatch.MetricAlarmMetricQueryArray{
&cloudwatch.MetricAlarmMetricQueryArgs{
Id: pulumi.String("e1"),
Expression: pulumi.String("ANOMALY_DETECTION_BAND(m1)"),
Label: pulumi.String("CPUUtilization (Expected)"),
ReturnData: pulumi.Bool(true),
},
&cloudwatch.MetricAlarmMetricQueryArgs{
Id: pulumi.String("m1"),
ReturnData: pulumi.Bool(true),
Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
MetricName: pulumi.String("CPUUtilization"),
Namespace: pulumi.String("AWS/EC2"),
Period: pulumi.Int(120),
Stat: pulumi.String("Average"),
Unit: pulumi.String("Count"),
Dimensions: pulumi.StringMap{
"InstanceId": pulumi.String("i-abc123"),
},
},
},
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var xxAnomalyDetection = new Aws.CloudWatch.MetricAlarm("xx_anomaly_detection", new()
{
Name = "test-foobar",
ComparisonOperator = "GreaterThanUpperThreshold",
EvaluationPeriods = 2,
ThresholdMetricId = "e1",
AlarmDescription = "This metric monitors ec2 cpu utilization",
InsufficientDataActions = new[] {},
MetricQueries = new[]
{
new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
{
Id = "e1",
Expression = "ANOMALY_DETECTION_BAND(m1)",
Label = "CPUUtilization (Expected)",
ReturnData = true,
},
new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
{
Id = "m1",
ReturnData = true,
Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
{
MetricName = "CPUUtilization",
Namespace = "AWS/EC2",
Period = 120,
Stat = "Average",
Unit = "Count",
Dimensions =
{
{ "InstanceId", "i-abc123" },
},
},
},
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.MetricAlarm;
import com.pulumi.aws.cloudwatch.MetricAlarmArgs;
import com.pulumi.aws.cloudwatch.inputs.MetricAlarmMetricQueryArgs;
import com.pulumi.aws.cloudwatch.inputs.MetricAlarmMetricQueryMetricArgs;
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 xxAnomalyDetection = new MetricAlarm("xxAnomalyDetection", MetricAlarmArgs.builder()
.name("test-foobar")
.comparisonOperator("GreaterThanUpperThreshold")
.evaluationPeriods(2)
.thresholdMetricId("e1")
.alarmDescription("This metric monitors ec2 cpu utilization")
.insufficientDataActions()
.metricQueries(
MetricAlarmMetricQueryArgs.builder()
.id("e1")
.expression("ANOMALY_DETECTION_BAND(m1)")
.label("CPUUtilization (Expected)")
.returnData("true")
.build(),
MetricAlarmMetricQueryArgs.builder()
.id("m1")
.returnData("true")
.metric(MetricAlarmMetricQueryMetricArgs.builder()
.metricName("CPUUtilization")
.namespace("AWS/EC2")
.period(120)
.stat("Average")
.unit("Count")
.dimensions(Map.of("InstanceId", "i-abc123"))
.build())
.build())
.build());
}
}
resources:
xxAnomalyDetection:
type: aws:cloudwatch:MetricAlarm
name: xx_anomaly_detection
properties:
name: test-foobar
comparisonOperator: GreaterThanUpperThreshold
evaluationPeriods: 2
thresholdMetricId: e1
alarmDescription: This metric monitors ec2 cpu utilization
insufficientDataActions: []
metricQueries:
- id: e1
expression: ANOMALY_DETECTION_BAND(m1)
label: CPUUtilization (Expected)
returnData: 'true'
- id: m1
returnData: 'true'
metric:
metricName: CPUUtilization
namespace: AWS/EC2
period: 120
stat: Average
unit: Count
dimensions:
InstanceId: i-abc123
Example of monitoring Healthy Hosts on NLB using Target Group and NLB
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const nlbHealthyhosts = new aws.cloudwatch.MetricAlarm("nlb_healthyhosts", {
name: "alarmname",
comparisonOperator: "LessThanThreshold",
evaluationPeriods: 1,
metricName: "HealthyHostCount",
namespace: "AWS/NetworkELB",
period: 60,
statistic: "Average",
threshold: logstashServersCount,
alarmDescription: "Number of healthy nodes in Target Group",
actionsEnabled: true,
alarmActions: [sns.arn],
okActions: [sns.arn],
dimensions: {
TargetGroup: lb_tg.arnSuffix,
LoadBalancer: lb.arnSuffix,
},
});
import pulumi
import pulumi_aws as aws
nlb_healthyhosts = aws.cloudwatch.MetricAlarm("nlb_healthyhosts",
name="alarmname",
comparison_operator="LessThanThreshold",
evaluation_periods=1,
metric_name="HealthyHostCount",
namespace="AWS/NetworkELB",
period=60,
statistic="Average",
threshold=logstash_servers_count,
alarm_description="Number of healthy nodes in Target Group",
actions_enabled=True,
alarm_actions=[sns["arn"]],
ok_actions=[sns["arn"]],
dimensions={
"TargetGroup": lb_tg["arnSuffix"],
"LoadBalancer": lb["arnSuffix"],
})
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudwatch"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/sns"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := cloudwatch.NewMetricAlarm(ctx, "nlb_healthyhosts", &cloudwatch.MetricAlarmArgs{
Name: pulumi.String("alarmname"),
ComparisonOperator: pulumi.String("LessThanThreshold"),
EvaluationPeriods: pulumi.Int(1),
MetricName: pulumi.String("HealthyHostCount"),
Namespace: pulumi.String("AWS/NetworkELB"),
Period: pulumi.Int(60),
Statistic: pulumi.String("Average"),
Threshold: pulumi.Any(logstashServersCount),
AlarmDescription: pulumi.String("Number of healthy nodes in Target Group"),
ActionsEnabled: pulumi.Bool(true),
AlarmActions: pulumi.Array{
sns.Arn,
},
OkActions: pulumi.Array{
sns.Arn,
},
Dimensions: pulumi.StringMap{
"TargetGroup": pulumi.Any(lb_tg.ArnSuffix),
"LoadBalancer": pulumi.Any(lb.ArnSuffix),
},
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var nlbHealthyhosts = new Aws.CloudWatch.MetricAlarm("nlb_healthyhosts", new()
{
Name = "alarmname",
ComparisonOperator = "LessThanThreshold",
EvaluationPeriods = 1,
MetricName = "HealthyHostCount",
Namespace = "AWS/NetworkELB",
Period = 60,
Statistic = "Average",
Threshold = logstashServersCount,
AlarmDescription = "Number of healthy nodes in Target Group",
ActionsEnabled = true,
AlarmActions = new[]
{
sns.Arn,
},
OkActions = new[]
{
sns.Arn,
},
Dimensions =
{
{ "TargetGroup", lb_tg.ArnSuffix },
{ "LoadBalancer", lb.ArnSuffix },
},
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.cloudwatch.MetricAlarm;
import com.pulumi.aws.cloudwatch.MetricAlarmArgs;
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 nlbHealthyhosts = new MetricAlarm("nlbHealthyhosts", MetricAlarmArgs.builder()
.name("alarmname")
.comparisonOperator("LessThanThreshold")
.evaluationPeriods(1)
.metricName("HealthyHostCount")
.namespace("AWS/NetworkELB")
.period(60)
.statistic("Average")
.threshold(logstashServersCount)
.alarmDescription("Number of healthy nodes in Target Group")
.actionsEnabled("true")
.alarmActions(sns.arn())
.okActions(sns.arn())
.dimensions(Map.ofEntries(
Map.entry("TargetGroup", lb_tg.arnSuffix()),
Map.entry("LoadBalancer", lb.arnSuffix())
))
.build());
}
}
resources:
nlbHealthyhosts:
type: aws:cloudwatch:MetricAlarm
name: nlb_healthyhosts
properties:
name: alarmname
comparisonOperator: LessThanThreshold
evaluationPeriods: 1
metricName: HealthyHostCount
namespace: AWS/NetworkELB
period: 60
statistic: Average
threshold: ${logstashServersCount}
alarmDescription: Number of healthy nodes in Target Group
actionsEnabled: 'true'
alarmActions:
- ${sns.arn}
okActions:
- ${sns.arn}
dimensions:
TargetGroup: ${["lb-tg"].arnSuffix}
LoadBalancer: ${lb.arnSuffix}
NOTE: You cannot create a metric alarm consisting of both
statistic
andextended_statistic
parameters. You must choose one or the other
Create MetricAlarm Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new MetricAlarm(name: string, args: MetricAlarmArgs, opts?: CustomResourceOptions);
@overload
def MetricAlarm(resource_name: str,
args: MetricAlarmArgs,
opts: Optional[ResourceOptions] = None)
@overload
def MetricAlarm(resource_name: str,
opts: Optional[ResourceOptions] = None,
comparison_operator: Optional[str] = None,
evaluation_periods: Optional[int] = None,
metric_name: Optional[str] = None,
metric_queries: Optional[Sequence[MetricAlarmMetricQueryArgs]] = None,
datapoints_to_alarm: Optional[int] = None,
dimensions: Optional[Mapping[str, str]] = None,
evaluate_low_sample_count_percentiles: Optional[str] = None,
alarm_actions: Optional[Sequence[str]] = None,
extended_statistic: Optional[str] = None,
insufficient_data_actions: Optional[Sequence[str]] = None,
actions_enabled: Optional[bool] = None,
alarm_description: Optional[str] = None,
name: Optional[str] = None,
namespace: Optional[str] = None,
ok_actions: Optional[Sequence[str]] = None,
period: Optional[int] = None,
statistic: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
threshold: Optional[float] = None,
threshold_metric_id: Optional[str] = None,
treat_missing_data: Optional[str] = None,
unit: Optional[str] = None)
func NewMetricAlarm(ctx *Context, name string, args MetricAlarmArgs, opts ...ResourceOption) (*MetricAlarm, error)
public MetricAlarm(string name, MetricAlarmArgs args, CustomResourceOptions? opts = null)
public MetricAlarm(String name, MetricAlarmArgs args)
public MetricAlarm(String name, MetricAlarmArgs args, CustomResourceOptions options)
type: aws:cloudwatch:MetricAlarm
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args MetricAlarmArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args MetricAlarmArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args MetricAlarmArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args MetricAlarmArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args MetricAlarmArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var metricAlarmResource = new Aws.CloudWatch.MetricAlarm("metricAlarmResource", new()
{
ComparisonOperator = "string",
EvaluationPeriods = 0,
MetricName = "string",
MetricQueries = new[]
{
new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
{
Id = "string",
AccountId = "string",
Expression = "string",
Label = "string",
Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
{
MetricName = "string",
Period = 0,
Stat = "string",
Dimensions =
{
{ "string", "string" },
},
Namespace = "string",
Unit = "string",
},
Period = 0,
ReturnData = false,
},
},
DatapointsToAlarm = 0,
Dimensions =
{
{ "string", "string" },
},
EvaluateLowSampleCountPercentiles = "string",
AlarmActions = new[]
{
"string",
},
ExtendedStatistic = "string",
InsufficientDataActions = new[]
{
"string",
},
ActionsEnabled = false,
AlarmDescription = "string",
Name = "string",
Namespace = "string",
OkActions = new[]
{
"string",
},
Period = 0,
Statistic = "string",
Tags =
{
{ "string", "string" },
},
Threshold = 0,
ThresholdMetricId = "string",
TreatMissingData = "string",
Unit = "string",
});
example, err := cloudwatch.NewMetricAlarm(ctx, "metricAlarmResource", &cloudwatch.MetricAlarmArgs{
ComparisonOperator: pulumi.String("string"),
EvaluationPeriods: pulumi.Int(0),
MetricName: pulumi.String("string"),
MetricQueries: cloudwatch.MetricAlarmMetricQueryArray{
&cloudwatch.MetricAlarmMetricQueryArgs{
Id: pulumi.String("string"),
AccountId: pulumi.String("string"),
Expression: pulumi.String("string"),
Label: pulumi.String("string"),
Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
MetricName: pulumi.String("string"),
Period: pulumi.Int(0),
Stat: pulumi.String("string"),
Dimensions: pulumi.StringMap{
"string": pulumi.String("string"),
},
Namespace: pulumi.String("string"),
Unit: pulumi.String("string"),
},
Period: pulumi.Int(0),
ReturnData: pulumi.Bool(false),
},
},
DatapointsToAlarm: pulumi.Int(0),
Dimensions: pulumi.StringMap{
"string": pulumi.String("string"),
},
EvaluateLowSampleCountPercentiles: pulumi.String("string"),
AlarmActions: pulumi.Array{
pulumi.Any("string"),
},
ExtendedStatistic: pulumi.String("string"),
InsufficientDataActions: pulumi.Array{
pulumi.Any("string"),
},
ActionsEnabled: pulumi.Bool(false),
AlarmDescription: pulumi.String("string"),
Name: pulumi.String("string"),
Namespace: pulumi.String("string"),
OkActions: pulumi.Array{
pulumi.Any("string"),
},
Period: pulumi.Int(0),
Statistic: pulumi.String("string"),
Tags: pulumi.StringMap{
"string": pulumi.String("string"),
},
Threshold: pulumi.Float64(0),
ThresholdMetricId: pulumi.String("string"),
TreatMissingData: pulumi.String("string"),
Unit: pulumi.String("string"),
})
var metricAlarmResource = new MetricAlarm("metricAlarmResource", MetricAlarmArgs.builder()
.comparisonOperator("string")
.evaluationPeriods(0)
.metricName("string")
.metricQueries(MetricAlarmMetricQueryArgs.builder()
.id("string")
.accountId("string")
.expression("string")
.label("string")
.metric(MetricAlarmMetricQueryMetricArgs.builder()
.metricName("string")
.period(0)
.stat("string")
.dimensions(Map.of("string", "string"))
.namespace("string")
.unit("string")
.build())
.period(0)
.returnData(false)
.build())
.datapointsToAlarm(0)
.dimensions(Map.of("string", "string"))
.evaluateLowSampleCountPercentiles("string")
.alarmActions("string")
.extendedStatistic("string")
.insufficientDataActions("string")
.actionsEnabled(false)
.alarmDescription("string")
.name("string")
.namespace("string")
.okActions("string")
.period(0)
.statistic("string")
.tags(Map.of("string", "string"))
.threshold(0)
.thresholdMetricId("string")
.treatMissingData("string")
.unit("string")
.build());
metric_alarm_resource = aws.cloudwatch.MetricAlarm("metricAlarmResource",
comparison_operator="string",
evaluation_periods=0,
metric_name="string",
metric_queries=[{
"id": "string",
"account_id": "string",
"expression": "string",
"label": "string",
"metric": {
"metric_name": "string",
"period": 0,
"stat": "string",
"dimensions": {
"string": "string",
},
"namespace": "string",
"unit": "string",
},
"period": 0,
"return_data": False,
}],
datapoints_to_alarm=0,
dimensions={
"string": "string",
},
evaluate_low_sample_count_percentiles="string",
alarm_actions=["string"],
extended_statistic="string",
insufficient_data_actions=["string"],
actions_enabled=False,
alarm_description="string",
name="string",
namespace="string",
ok_actions=["string"],
period=0,
statistic="string",
tags={
"string": "string",
},
threshold=0,
threshold_metric_id="string",
treat_missing_data="string",
unit="string")
const metricAlarmResource = new aws.cloudwatch.MetricAlarm("metricAlarmResource", {
comparisonOperator: "string",
evaluationPeriods: 0,
metricName: "string",
metricQueries: [{
id: "string",
accountId: "string",
expression: "string",
label: "string",
metric: {
metricName: "string",
period: 0,
stat: "string",
dimensions: {
string: "string",
},
namespace: "string",
unit: "string",
},
period: 0,
returnData: false,
}],
datapointsToAlarm: 0,
dimensions: {
string: "string",
},
evaluateLowSampleCountPercentiles: "string",
alarmActions: ["string"],
extendedStatistic: "string",
insufficientDataActions: ["string"],
actionsEnabled: false,
alarmDescription: "string",
name: "string",
namespace: "string",
okActions: ["string"],
period: 0,
statistic: "string",
tags: {
string: "string",
},
threshold: 0,
thresholdMetricId: "string",
treatMissingData: "string",
unit: "string",
});
type: aws:cloudwatch:MetricAlarm
properties:
actionsEnabled: false
alarmActions:
- string
alarmDescription: string
comparisonOperator: string
datapointsToAlarm: 0
dimensions:
string: string
evaluateLowSampleCountPercentiles: string
evaluationPeriods: 0
extendedStatistic: string
insufficientDataActions:
- string
metricName: string
metricQueries:
- accountId: string
expression: string
id: string
label: string
metric:
dimensions:
string: string
metricName: string
namespace: string
period: 0
stat: string
unit: string
period: 0
returnData: false
name: string
namespace: string
okActions:
- string
period: 0
statistic: string
tags:
string: string
threshold: 0
thresholdMetricId: string
treatMissingData: string
unit: string
MetricAlarm Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The MetricAlarm resource accepts the following input properties:
- Comparison
Operator string - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - Evaluation
Periods int - The number of periods over which data is compared to the specified threshold.
- Actions
Enabled bool - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - Alarm
Actions List<string> - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Alarm
Description string - The description for the alarm.
- Datapoints
To intAlarm - The number of datapoints that must be breaching to trigger the alarm.
- Dimensions Dictionary<string, string>
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- Evaluate
Low stringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - Extended
Statistic string - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- Insufficient
Data List<string>Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Metric
Name string - The name for the alarm's associated metric. See docs for supported metrics.
- Metric
Queries List<MetricAlarm Metric Query> - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- Name string
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- Namespace string
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- Ok
Actions List<string> - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Period int
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - Statistic string
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Dictionary<string, string>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- Threshold double
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- Threshold
Metric stringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- Treat
Missing stringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - Unit string
- The unit for the alarm's associated metric.
- Comparison
Operator string - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - Evaluation
Periods int - The number of periods over which data is compared to the specified threshold.
- Actions
Enabled bool - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - Alarm
Actions []interface{} - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Alarm
Description string - The description for the alarm.
- Datapoints
To intAlarm - The number of datapoints that must be breaching to trigger the alarm.
- Dimensions map[string]string
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- Evaluate
Low stringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - Extended
Statistic string - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- Insufficient
Data []interface{}Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Metric
Name string - The name for the alarm's associated metric. See docs for supported metrics.
- Metric
Queries []MetricAlarm Metric Query Args - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- Name string
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- Namespace string
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- Ok
Actions []interface{} - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Period int
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - Statistic string
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- map[string]string
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- Threshold float64
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- Threshold
Metric stringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- Treat
Missing stringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - Unit string
- The unit for the alarm's associated metric.
- comparison
Operator String - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - evaluation
Periods Integer - The number of periods over which data is compared to the specified threshold.
- actions
Enabled Boolean - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm
Actions List<String> - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm
Description String - The description for the alarm.
- datapoints
To IntegerAlarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions Map<String,String>
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate
Low StringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - extended
Statistic String - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient
Data List<String>Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric
Name String - The name for the alarm's associated metric. See docs for supported metrics.
- metric
Queries List<MetricAlarm Metric Query> - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name String
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace String
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok
Actions List<String> - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period Integer
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic String
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Map<String,String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- threshold Double
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold
Metric StringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat
Missing StringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit String
- The unit for the alarm's associated metric.
- comparison
Operator string - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - evaluation
Periods number - The number of periods over which data is compared to the specified threshold.
- actions
Enabled boolean - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm
Actions (string | Topic)[] - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm
Description string - The description for the alarm.
- datapoints
To numberAlarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions {[key: string]: string}
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate
Low stringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - extended
Statistic string - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient
Data (string | Topic)[]Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric
Name string - The name for the alarm's associated metric. See docs for supported metrics.
- metric
Queries MetricAlarm Metric Query[] - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name string
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace string
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok
Actions (string | Topic)[] - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period number
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic string
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- {[key: string]: string}
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- threshold number
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold
Metric stringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat
Missing stringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit string
- The unit for the alarm's associated metric.
- comparison_
operator str - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - evaluation_
periods int - The number of periods over which data is compared to the specified threshold.
- actions_
enabled bool - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm_
actions Sequence[str] - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm_
description str - The description for the alarm.
- datapoints_
to_ intalarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions Mapping[str, str]
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate_
low_ strsample_ count_ percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - extended_
statistic str - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient_
data_ Sequence[str]actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric_
name str - The name for the alarm's associated metric. See docs for supported metrics.
- metric_
queries Sequence[MetricAlarm Metric Query Args] - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name str
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace str
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok_
actions Sequence[str] - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period int
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic str
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Mapping[str, str]
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- threshold float
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold_
metric_ strid - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat_
missing_ strdata - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit str
- The unit for the alarm's associated metric.
- comparison
Operator String - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - evaluation
Periods Number - The number of periods over which data is compared to the specified threshold.
- actions
Enabled Boolean - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm
Actions List<String | > - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm
Description String - The description for the alarm.
- datapoints
To NumberAlarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions Map<String>
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate
Low StringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - extended
Statistic String - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient
Data List<String | >Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric
Name String - The name for the alarm's associated metric. See docs for supported metrics.
- metric
Queries List<Property Map> - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name String
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace String
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok
Actions List<String | > - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period Number
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic String
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Map<String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- threshold Number
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold
Metric StringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat
Missing StringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit String
- The unit for the alarm's associated metric.
Outputs
All input properties are implicitly available as output properties. Additionally, the MetricAlarm resource produces the following output properties:
Look up Existing MetricAlarm Resource
Get an existing MetricAlarm resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: MetricAlarmState, opts?: CustomResourceOptions): MetricAlarm
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
actions_enabled: Optional[bool] = None,
alarm_actions: Optional[Sequence[str]] = None,
alarm_description: Optional[str] = None,
arn: Optional[str] = None,
comparison_operator: Optional[str] = None,
datapoints_to_alarm: Optional[int] = None,
dimensions: Optional[Mapping[str, str]] = None,
evaluate_low_sample_count_percentiles: Optional[str] = None,
evaluation_periods: Optional[int] = None,
extended_statistic: Optional[str] = None,
insufficient_data_actions: Optional[Sequence[str]] = None,
metric_name: Optional[str] = None,
metric_queries: Optional[Sequence[MetricAlarmMetricQueryArgs]] = None,
name: Optional[str] = None,
namespace: Optional[str] = None,
ok_actions: Optional[Sequence[str]] = None,
period: Optional[int] = None,
statistic: Optional[str] = None,
tags: Optional[Mapping[str, str]] = None,
tags_all: Optional[Mapping[str, str]] = None,
threshold: Optional[float] = None,
threshold_metric_id: Optional[str] = None,
treat_missing_data: Optional[str] = None,
unit: Optional[str] = None) -> MetricAlarm
func GetMetricAlarm(ctx *Context, name string, id IDInput, state *MetricAlarmState, opts ...ResourceOption) (*MetricAlarm, error)
public static MetricAlarm Get(string name, Input<string> id, MetricAlarmState? state, CustomResourceOptions? opts = null)
public static MetricAlarm get(String name, Output<String> id, MetricAlarmState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Actions
Enabled bool - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - Alarm
Actions List<string> - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Alarm
Description string - The description for the alarm.
- Arn string
- The ARN of the CloudWatch Metric Alarm.
- Comparison
Operator string - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - Datapoints
To intAlarm - The number of datapoints that must be breaching to trigger the alarm.
- Dimensions Dictionary<string, string>
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- Evaluate
Low stringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - Evaluation
Periods int - The number of periods over which data is compared to the specified threshold.
- Extended
Statistic string - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- Insufficient
Data List<string>Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Metric
Name string - The name for the alarm's associated metric. See docs for supported metrics.
- Metric
Queries List<MetricAlarm Metric Query> - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- Name string
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- Namespace string
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- Ok
Actions List<string> - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Period int
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - Statistic string
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Dictionary<string, string>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- Dictionary<string, string>
- A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block. - Threshold double
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- Threshold
Metric stringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- Treat
Missing stringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - Unit string
- The unit for the alarm's associated metric.
- Actions
Enabled bool - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - Alarm
Actions []interface{} - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Alarm
Description string - The description for the alarm.
- Arn string
- The ARN of the CloudWatch Metric Alarm.
- Comparison
Operator string - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - Datapoints
To intAlarm - The number of datapoints that must be breaching to trigger the alarm.
- Dimensions map[string]string
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- Evaluate
Low stringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - Evaluation
Periods int - The number of periods over which data is compared to the specified threshold.
- Extended
Statistic string - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- Insufficient
Data []interface{}Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Metric
Name string - The name for the alarm's associated metric. See docs for supported metrics.
- Metric
Queries []MetricAlarm Metric Query Args - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- Name string
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- Namespace string
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- Ok
Actions []interface{} - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- Period int
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - Statistic string
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- map[string]string
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- map[string]string
- A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block. - Threshold float64
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- Threshold
Metric stringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- Treat
Missing stringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - Unit string
- The unit for the alarm's associated metric.
- actions
Enabled Boolean - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm
Actions List<String> - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm
Description String - The description for the alarm.
- arn String
- The ARN of the CloudWatch Metric Alarm.
- comparison
Operator String - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - datapoints
To IntegerAlarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions Map<String,String>
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate
Low StringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - evaluation
Periods Integer - The number of periods over which data is compared to the specified threshold.
- extended
Statistic String - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient
Data List<String>Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric
Name String - The name for the alarm's associated metric. See docs for supported metrics.
- metric
Queries List<MetricAlarm Metric Query> - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name String
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace String
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok
Actions List<String> - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period Integer
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic String
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Map<String,String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- Map<String,String>
- A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block. - threshold Double
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold
Metric StringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat
Missing StringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit String
- The unit for the alarm's associated metric.
- actions
Enabled boolean - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm
Actions (string | Topic)[] - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm
Description string - The description for the alarm.
- arn string
- The ARN of the CloudWatch Metric Alarm.
- comparison
Operator string - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - datapoints
To numberAlarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions {[key: string]: string}
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate
Low stringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - evaluation
Periods number - The number of periods over which data is compared to the specified threshold.
- extended
Statistic string - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient
Data (string | Topic)[]Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric
Name string - The name for the alarm's associated metric. See docs for supported metrics.
- metric
Queries MetricAlarm Metric Query[] - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name string
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace string
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok
Actions (string | Topic)[] - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period number
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic string
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- {[key: string]: string}
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- {[key: string]: string}
- A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block. - threshold number
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold
Metric stringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat
Missing stringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit string
- The unit for the alarm's associated metric.
- actions_
enabled bool - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm_
actions Sequence[str] - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm_
description str - The description for the alarm.
- arn str
- The ARN of the CloudWatch Metric Alarm.
- comparison_
operator str - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - datapoints_
to_ intalarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions Mapping[str, str]
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate_
low_ strsample_ count_ percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - evaluation_
periods int - The number of periods over which data is compared to the specified threshold.
- extended_
statistic str - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient_
data_ Sequence[str]actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric_
name str - The name for the alarm's associated metric. See docs for supported metrics.
- metric_
queries Sequence[MetricAlarm Metric Query Args] - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name str
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace str
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok_
actions Sequence[str] - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period int
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic str
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Mapping[str, str]
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- Mapping[str, str]
- A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block. - threshold float
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold_
metric_ strid - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat_
missing_ strdata - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit str
- The unit for the alarm's associated metric.
- actions
Enabled Boolean - Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to
true
. - alarm
Actions List<String | > - The list of actions to execute when this alarm transitions into an ALARM state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- alarm
Description String - The description for the alarm.
- arn String
- The ARN of the CloudWatch Metric Alarm.
- comparison
Operator String - The arithmetic operation to use when comparing the specified Statistic and Threshold. The specified Statistic value is used as the first operand. Either of the following is supported:
GreaterThanOrEqualToThreshold
,GreaterThanThreshold
,LessThanThreshold
,LessThanOrEqualToThreshold
. Additionally, the valuesLessThanLowerOrGreaterThanUpperThreshold
,LessThanLowerThreshold
, andGreaterThanUpperThreshold
are used only for alarms based on anomaly detection models. - datapoints
To NumberAlarm - The number of datapoints that must be breaching to trigger the alarm.
- dimensions Map<String>
- The dimensions for the alarm's associated metric. For the list of available dimensions see the AWS documentation here.
- evaluate
Low StringSample Count Percentiles - Used only for alarms based on percentiles.
If you specify
ignore
, the alarm state will not change during periods with too few data points to be statistically significant. If you specifyevaluate
or omit this parameter, the alarm will always be evaluated and possibly change state no matter how many data points are available. The following values are supported:ignore
, andevaluate
. - evaluation
Periods Number - The number of periods over which data is compared to the specified threshold.
- extended
Statistic String - The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
- insufficient
Data List<String | >Actions - The list of actions to execute when this alarm transitions into an INSUFFICIENT_DATA state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- metric
Name String - The name for the alarm's associated metric. See docs for supported metrics.
- metric
Queries List<Property Map> - Enables you to create an alarm based on a metric math expression. You may specify at most 20.
- name String
- The descriptive name for the alarm. This name must be unique within the user's AWS account
- namespace String
- The namespace for the alarm's associated metric. See docs for the list of namespaces. See docs for supported metrics.
- ok
Actions List<String | > - The list of actions to execute when this alarm transitions into an OK state from any other state. Each action is specified as an Amazon Resource Name (ARN).
- period Number
- The period in seconds over which the specified
statistic
is applied. Valid values are10
,30
, or any multiple of60
. - statistic String
- The statistic to apply to the alarm's associated metric.
Either of the following is supported:
SampleCount
,Average
,Sum
,Minimum
,Maximum
- Map<String>
A map of tags to assign to the resource. .If configured with a provider
default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.NOTE: If you specify at least one
metric_query
, you may not specify ametric_name
,namespace
,period
orstatistic
. If you do not specify ametric_query
, you must specify each of these (although you may useextended_statistic
instead ofstatistic
).- Map<String>
- A map of tags assigned to the resource, including those inherited from the provider
default_tags
configuration block. - threshold Number
- The value against which the specified statistic is compared. This parameter is required for alarms based on static thresholds, but should not be used for alarms based on anomaly detection models.
- threshold
Metric StringId - If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.
- treat
Missing StringData - Sets how this alarm is to handle missing data points. The following values are supported:
missing
,ignore
,breaching
andnotBreaching
. Defaults tomissing
. - unit String
- The unit for the alarm's associated metric.
Supporting Types
MetricAlarmMetricQuery, MetricAlarmMetricQueryArgs
- Id string
- A short name used to tie this object to the results in the response. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- Account
Id string - The ID of the account where the metrics are located, if this is a cross-account alarm.
- Expression string
- The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the id of the other metrics to refer to those metrics, and can also use the id of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
- Label string
- A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents.
- Metric
Metric
Alarm Metric Query Metric - The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
- Period int
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - Return
Data bool Specify exactly one
metric_query
to betrue
to use thatmetric_query
result as the alarm.NOTE: You must specify either
metric
orexpression
. Not both.
- Id string
- A short name used to tie this object to the results in the response. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- Account
Id string - The ID of the account where the metrics are located, if this is a cross-account alarm.
- Expression string
- The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the id of the other metrics to refer to those metrics, and can also use the id of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
- Label string
- A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents.
- Metric
Metric
Alarm Metric Query Metric - The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
- Period int
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - Return
Data bool Specify exactly one
metric_query
to betrue
to use thatmetric_query
result as the alarm.NOTE: You must specify either
metric
orexpression
. Not both.
- id String
- A short name used to tie this object to the results in the response. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- account
Id String - The ID of the account where the metrics are located, if this is a cross-account alarm.
- expression String
- The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the id of the other metrics to refer to those metrics, and can also use the id of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
- label String
- A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents.
- metric
Metric
Alarm Metric Query Metric - The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
- period Integer
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - return
Data Boolean Specify exactly one
metric_query
to betrue
to use thatmetric_query
result as the alarm.NOTE: You must specify either
metric
orexpression
. Not both.
- id string
- A short name used to tie this object to the results in the response. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- account
Id string - The ID of the account where the metrics are located, if this is a cross-account alarm.
- expression string
- The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the id of the other metrics to refer to those metrics, and can also use the id of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
- label string
- A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents.
- metric
Metric
Alarm Metric Query Metric - The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
- period number
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - return
Data boolean Specify exactly one
metric_query
to betrue
to use thatmetric_query
result as the alarm.NOTE: You must specify either
metric
orexpression
. Not both.
- id str
- A short name used to tie this object to the results in the response. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- account_
id str - The ID of the account where the metrics are located, if this is a cross-account alarm.
- expression str
- The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the id of the other metrics to refer to those metrics, and can also use the id of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
- label str
- A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents.
- metric
Metric
Alarm Metric Query Metric - The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
- period int
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - return_
data bool Specify exactly one
metric_query
to betrue
to use thatmetric_query
result as the alarm.NOTE: You must specify either
metric
orexpression
. Not both.
- id String
- A short name used to tie this object to the results in the response. If you are performing math expressions on this set of data, this name represents that data and can serve as a variable in the mathematical expression. The valid characters are letters, numbers, and underscore. The first character must be a lowercase letter.
- account
Id String - The ID of the account where the metrics are located, if this is a cross-account alarm.
- expression String
- The math expression to be performed on the returned data, if this object is performing a math expression. This expression can use the id of the other metrics to refer to those metrics, and can also use the id of other expressions to use the result of those expressions. For more information about metric math expressions, see Metric Math Syntax and Functions in the Amazon CloudWatch User Guide.
- label String
- A human-readable label for this metric or expression. This is especially useful if this is an expression, so that you know what the value represents.
- metric Property Map
- The metric to be returned, along with statistics, period, and units. Use this parameter only if this object is retrieving a metric and not performing a math expression on returned data.
- period Number
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - return
Data Boolean Specify exactly one
metric_query
to betrue
to use thatmetric_query
result as the alarm.NOTE: You must specify either
metric
orexpression
. Not both.
MetricAlarmMetricQueryMetric, MetricAlarmMetricQueryMetricArgs
- Metric
Name string - The name for this metric. See docs for supported metrics.
- Period int
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - Stat string
- The statistic to apply to this metric. See docs for supported statistics.
- Dimensions Dictionary<string, string>
- The dimensions for this metric. For the list of available dimensions see the AWS documentation here.
- Namespace string
- The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.
- Unit string
- The unit for this metric.
- Metric
Name string - The name for this metric. See docs for supported metrics.
- Period int
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - Stat string
- The statistic to apply to this metric. See docs for supported statistics.
- Dimensions map[string]string
- The dimensions for this metric. For the list of available dimensions see the AWS documentation here.
- Namespace string
- The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.
- Unit string
- The unit for this metric.
- metric
Name String - The name for this metric. See docs for supported metrics.
- period Integer
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - stat String
- The statistic to apply to this metric. See docs for supported statistics.
- dimensions Map<String,String>
- The dimensions for this metric. For the list of available dimensions see the AWS documentation here.
- namespace String
- The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.
- unit String
- The unit for this metric.
- metric
Name string - The name for this metric. See docs for supported metrics.
- period number
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - stat string
- The statistic to apply to this metric. See docs for supported statistics.
- dimensions {[key: string]: string}
- The dimensions for this metric. For the list of available dimensions see the AWS documentation here.
- namespace string
- The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.
- unit string
- The unit for this metric.
- metric_
name str - The name for this metric. See docs for supported metrics.
- period int
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - stat str
- The statistic to apply to this metric. See docs for supported statistics.
- dimensions Mapping[str, str]
- The dimensions for this metric. For the list of available dimensions see the AWS documentation here.
- namespace str
- The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.
- unit str
- The unit for this metric.
- metric
Name String - The name for this metric. See docs for supported metrics.
- period Number
- Granularity in seconds of returned data points.
For metrics with regular resolution, valid values are any multiple of
60
. For high-resolution metrics, valid values are1
,5
,10
,30
, or any multiple of60
. - stat String
- The statistic to apply to this metric. See docs for supported statistics.
- dimensions Map<String>
- The dimensions for this metric. For the list of available dimensions see the AWS documentation here.
- namespace String
- The namespace for this metric. See docs for the list of namespaces. See docs for supported metrics.
- unit String
- The unit for this metric.
Import
Using pulumi import
, import CloudWatch Metric Alarm using the alarm_name
. For example:
$ pulumi import aws:cloudwatch/metricAlarm:MetricAlarm test alarm-12345
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.