AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.10.0 published on Monday, Jul 11, 2022 by Pulumi

MetricAlarm

Provides a CloudWatch Metric Alarm resource.

Example in Conjunction with Scaling Policies

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const batPolicy = new aws.autoscaling.Policy("batPolicy", {
    scalingAdjustment: 4,
    adjustmentType: "ChangeInCapacity",
    cooldown: 300,
    autoscalingGroupName: aws_autoscaling_group.bar.name,
});
const batMetricAlarm = new aws.cloudwatch.MetricAlarm("batMetricAlarm", {
    comparisonOperator: "GreaterThanOrEqualToThreshold",
    evaluationPeriods: 2,
    metricName: "CPUUtilization",
    namespace: "AWS/EC2",
    period: 120,
    statistic: "Average",
    threshold: 80,
    dimensions: {
        AutoScalingGroupName: aws_autoscaling_group.bar.name,
    },
    alarmDescription: "This metric monitors ec2 cpu utilization",
    alarmActions: [batPolicy.arn],
});
import pulumi
import pulumi_aws as aws

bat_policy = aws.autoscaling.Policy("batPolicy",
    scaling_adjustment=4,
    adjustment_type="ChangeInCapacity",
    cooldown=300,
    autoscaling_group_name=aws_autoscaling_group["bar"]["name"])
bat_metric_alarm = aws.cloudwatch.MetricAlarm("batMetricAlarm",
    comparison_operator="GreaterThanOrEqualToThreshold",
    evaluation_periods=2,
    metric_name="CPUUtilization",
    namespace="AWS/EC2",
    period=120,
    statistic="Average",
    threshold=80,
    dimensions={
        "AutoScalingGroupName": aws_autoscaling_group["bar"]["name"],
    },
    alarm_description="This metric monitors ec2 cpu utilization",
    alarm_actions=[bat_policy.arn])
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var batPolicy = new Aws.AutoScaling.Policy("batPolicy", new Aws.AutoScaling.PolicyArgs
        {
            ScalingAdjustment = 4,
            AdjustmentType = "ChangeInCapacity",
            Cooldown = 300,
            AutoscalingGroupName = aws_autoscaling_group.Bar.Name,
        });
        var batMetricAlarm = new Aws.CloudWatch.MetricAlarm("batMetricAlarm", new Aws.CloudWatch.MetricAlarmArgs
        {
            ComparisonOperator = "GreaterThanOrEqualToThreshold",
            EvaluationPeriods = 2,
            MetricName = "CPUUtilization",
            Namespace = "AWS/EC2",
            Period = 120,
            Statistic = "Average",
            Threshold = 80,
            Dimensions = 
            {
                { "AutoScalingGroupName", aws_autoscaling_group.Bar.Name },
            },
            AlarmDescription = "This metric monitors ec2 cpu utilization",
            AlarmActions = 
            {
                batPolicy.Arn,
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/autoscaling"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sns"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		batPolicy, err := autoscaling.NewPolicy(ctx, "batPolicy", &autoscaling.PolicyArgs{
			ScalingAdjustment:    pulumi.Int(4),
			AdjustmentType:       pulumi.String("ChangeInCapacity"),
			Cooldown:             pulumi.Int(300),
			AutoscalingGroupName: pulumi.Any(aws_autoscaling_group.Bar.Name),
		})
		if err != nil {
			return err
		}
		_, err = cloudwatch.NewMetricAlarm(ctx, "batMetricAlarm", &cloudwatch.MetricAlarmArgs{
			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(aws_autoscaling_group.Bar.Name),
			},
			AlarmDescription: pulumi.String("This metric monitors ec2 cpu utilization"),
			AlarmActions: pulumi.AnyArray{
				batPolicy.Arn,
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var batPolicy = new Policy("batPolicy", PolicyArgs.builder()        
            .scalingAdjustment(4)
            .adjustmentType("ChangeInCapacity")
            .cooldown(300)
            .autoscalingGroupName(aws_autoscaling_group.bar().name())
            .build());

        var batMetricAlarm = new MetricAlarm("batMetricAlarm", MetricAlarmArgs.builder()        
            .comparisonOperator("GreaterThanOrEqualToThreshold")
            .evaluationPeriods("2")
            .metricName("CPUUtilization")
            .namespace("AWS/EC2")
            .period("120")
            .statistic("Average")
            .threshold("80")
            .dimensions(Map.of("AutoScalingGroupName", aws_autoscaling_group.bar().name()))
            .alarmDescription("This metric monitors ec2 cpu utilization")
            .alarmActions(batPolicy.arn())
            .build());

    }
}
resources:
  batPolicy:
    type: aws:autoscaling:Policy
    properties:
      scalingAdjustment: 4
      adjustmentType: ChangeInCapacity
      cooldown: 300
      autoscalingGroupName: ${aws_autoscaling_group.bar.name}
  batMetricAlarm:
    type: aws:cloudwatch:MetricAlarm
    properties:
      comparisonOperator: GreaterThanOrEqualToThreshold
      evaluationPeriods: 2
      metricName: CPUUtilization
      namespace: AWS/EC2
      period: 120
      statistic: Average
      threshold: 80
      dimensions:
        AutoScalingGroupName: ${aws_autoscaling_group.bar.name}
      alarmDescription: This metric monitors ec2 cpu utilization
      alarmActions:
        - ${batPolicy.arn}

Example with an Expression

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const foobar = new aws.cloudwatch.MetricAlarm("foobar", {
    alarmDescription: "Request error rate has exceeded 10%",
    comparisonOperator: "GreaterThanOrEqualToThreshold",
    evaluationPeriods: 2,
    insufficientDataActions: [],
    metricQueries: [
        {
            expression: "m2/m1*100",
            id: "e1",
            label: "Error Rate",
            returnData: true,
        },
        {
            id: "m1",
            metric: {
                dimensions: {
                    LoadBalancer: "app/web",
                },
                metricName: "RequestCount",
                namespace: "AWS/ApplicationELB",
                period: 120,
                stat: "Sum",
                unit: "Count",
            },
        },
        {
            id: "m2",
            metric: {
                dimensions: {
                    LoadBalancer: "app/web",
                },
                metricName: "HTTPCode_ELB_5XX_Count",
                namespace: "AWS/ApplicationELB",
                period: 120,
                stat: "Sum",
                unit: "Count",
            },
        },
    ],
    threshold: 10,
});
import pulumi
import pulumi_aws as aws

foobar = aws.cloudwatch.MetricAlarm("foobar",
    alarm_description="Request error rate has exceeded 10%",
    comparison_operator="GreaterThanOrEqualToThreshold",
    evaluation_periods=2,
    insufficient_data_actions=[],
    metric_queries=[
        aws.cloudwatch.MetricAlarmMetricQueryArgs(
            expression="m2/m1*100",
            id="e1",
            label="Error Rate",
            return_data=True,
        ),
        aws.cloudwatch.MetricAlarmMetricQueryArgs(
            id="m1",
            metric=aws.cloudwatch.MetricAlarmMetricQueryMetricArgs(
                dimensions={
                    "LoadBalancer": "app/web",
                },
                metric_name="RequestCount",
                namespace="AWS/ApplicationELB",
                period=120,
                stat="Sum",
                unit="Count",
            ),
        ),
        aws.cloudwatch.MetricAlarmMetricQueryArgs(
            id="m2",
            metric=aws.cloudwatch.MetricAlarmMetricQueryMetricArgs(
                dimensions={
                    "LoadBalancer": "app/web",
                },
                metric_name="HTTPCode_ELB_5XX_Count",
                namespace="AWS/ApplicationELB",
                period=120,
                stat="Sum",
                unit="Count",
            ),
        ),
    ],
    threshold=10)
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var foobar = new Aws.CloudWatch.MetricAlarm("foobar", new Aws.CloudWatch.MetricAlarmArgs
        {
            AlarmDescription = "Request error rate has exceeded 10%",
            ComparisonOperator = "GreaterThanOrEqualToThreshold",
            EvaluationPeriods = 2,
            InsufficientDataActions = {},
            MetricQueries = 
            {
                new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
                {
                    Expression = "m2/m1*100",
                    Id = "e1",
                    Label = "Error Rate",
                    ReturnData = true,
                },
                new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
                {
                    Id = "m1",
                    Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
                    {
                        Dimensions = 
                        {
                            { "LoadBalancer", "app/web" },
                        },
                        MetricName = "RequestCount",
                        Namespace = "AWS/ApplicationELB",
                        Period = 120,
                        Stat = "Sum",
                        Unit = "Count",
                    },
                },
                new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
                {
                    Id = "m2",
                    Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
                    {
                        Dimensions = 
                        {
                            { "LoadBalancer", "app/web" },
                        },
                        MetricName = "HTTPCode_ELB_5XX_Count",
                        Namespace = "AWS/ApplicationELB",
                        Period = 120,
                        Stat = "Sum",
                        Unit = "Count",
                    },
                },
            },
            Threshold = 10,
        });
    }

}
package main

import (
	"fmt"

	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
	"github.com/pulumi/pulumi-aws/sdk/v5/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{
			AlarmDescription:        pulumi.String(fmt.Sprintf("%v%v", "Request error rate has exceeded 10", "%")),
			ComparisonOperator:      pulumi.String("GreaterThanOrEqualToThreshold"),
			EvaluationPeriods:       pulumi.Int(2),
			InsufficientDataActions: pulumi.AnyArray{},
			MetricQueries: cloudwatch.MetricAlarmMetricQueryArray{
				&cloudwatch.MetricAlarmMetricQueryArgs{
					Expression: pulumi.String("m2/m1*100"),
					Id:         pulumi.String("e1"),
					Label:      pulumi.String("Error Rate"),
					ReturnData: pulumi.Bool(true),
				},
				&cloudwatch.MetricAlarmMetricQueryArgs{
					Id: pulumi.String("m1"),
					Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
						Dimensions: pulumi.StringMap{
							"LoadBalancer": pulumi.String("app/web"),
						},
						MetricName: pulumi.String("RequestCount"),
						Namespace:  pulumi.String("AWS/ApplicationELB"),
						Period:     pulumi.Int(120),
						Stat:       pulumi.String("Sum"),
						Unit:       pulumi.String("Count"),
					},
				},
				&cloudwatch.MetricAlarmMetricQueryArgs{
					Id: pulumi.String("m2"),
					Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
						Dimensions: pulumi.StringMap{
							"LoadBalancer": pulumi.String("app/web"),
						},
						MetricName: pulumi.String("HTTPCode_ELB_5XX_Count"),
						Namespace:  pulumi.String("AWS/ApplicationELB"),
						Period:     pulumi.Int(120),
						Stat:       pulumi.String("Sum"),
						Unit:       pulumi.String("Count"),
					},
				},
			},
			Threshold: pulumi.Float64(10),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

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()        
            .alarmDescription("Request error rate has exceeded 10%")
            .comparisonOperator("GreaterThanOrEqualToThreshold")
            .evaluationPeriods("2")
            .insufficientDataActions()
            .metricQueries(            
                MetricAlarmMetricQueryArgs.builder()
                    .expression("m2/m1*100")
                    .id("e1")
                    .label("Error Rate")
                    .returnData("true")
                    .build(),
                MetricAlarmMetricQueryArgs.builder()
                    .id("m1")
                    .metric(MetricAlarmMetricQueryMetricArgs.builder()
                        .dimensions(Map.of("LoadBalancer", "app/web"))
                        .metricName("RequestCount")
                        .namespace("AWS/ApplicationELB")
                        .period("120")
                        .stat("Sum")
                        .unit("Count")
                        .build())
                    .build(),
                MetricAlarmMetricQueryArgs.builder()
                    .id("m2")
                    .metric(MetricAlarmMetricQueryMetricArgs.builder()
                        .dimensions(Map.of("LoadBalancer", "app/web"))
                        .metricName("HTTPCode_ELB_5XX_Count")
                        .namespace("AWS/ApplicationELB")
                        .period("120")
                        .stat("Sum")
                        .unit("Count")
                        .build())
                    .build())
            .threshold("10")
            .build());

    }
}
resources:
  foobar:
    type: aws:cloudwatch:MetricAlarm
    properties:
      alarmDescription: Request error rate has exceeded 10%
      comparisonOperator: GreaterThanOrEqualToThreshold
      evaluationPeriods: 2
      insufficientDataActions: []
      metricQueries:
        - expression: m2/m1*100
          id: e1
          label: Error Rate
          returnData: true
        - id: m1
          metric:
            dimensions:
              LoadBalancer: app/web
            metricName: RequestCount
            namespace: AWS/ApplicationELB
            period: 120
            stat: Sum
            unit: Count
        - id: m2
          metric:
            dimensions:
              LoadBalancer: app/web
            metricName: HTTPCode_ELB_5XX_Count
            namespace: AWS/ApplicationELB
            period: 120
            stat: Sum
            unit: Count
      threshold: 10
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const xxAnomalyDetection = new aws.cloudwatch.MetricAlarm("xx_anomaly_detection", {
    alarmDescription: "This metric monitors ec2 cpu utilization",
    comparisonOperator: "GreaterThanUpperThreshold",
    evaluationPeriods: 2,
    insufficientDataActions: [],
    metricQueries: [
        {
            expression: "ANOMALY_DETECTION_BAND(m1)",
            id: "e1",
            label: "CPUUtilization (Expected)",
            returnData: true,
        },
        {
            id: "m1",
            metric: {
                dimensions: {
                    InstanceId: "i-abc123",
                },
                metricName: "CPUUtilization",
                namespace: "AWS/EC2",
                period: 120,
                stat: "Average",
                unit: "Count",
            },
            returnData: true,
        },
    ],
    thresholdMetricId: "e1",
});
import pulumi
import pulumi_aws as aws

xx_anomaly_detection = aws.cloudwatch.MetricAlarm("xxAnomalyDetection",
    alarm_description="This metric monitors ec2 cpu utilization",
    comparison_operator="GreaterThanUpperThreshold",
    evaluation_periods=2,
    insufficient_data_actions=[],
    metric_queries=[
        aws.cloudwatch.MetricAlarmMetricQueryArgs(
            expression="ANOMALY_DETECTION_BAND(m1)",
            id="e1",
            label="CPUUtilization (Expected)",
            return_data=True,
        ),
        aws.cloudwatch.MetricAlarmMetricQueryArgs(
            id="m1",
            metric=aws.cloudwatch.MetricAlarmMetricQueryMetricArgs(
                dimensions={
                    "InstanceId": "i-abc123",
                },
                metric_name="CPUUtilization",
                namespace="AWS/EC2",
                period=120,
                stat="Average",
                unit="Count",
            ),
            return_data=True,
        ),
    ],
    threshold_metric_id="e1")
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var xxAnomalyDetection = new Aws.CloudWatch.MetricAlarm("xxAnomalyDetection", new Aws.CloudWatch.MetricAlarmArgs
        {
            AlarmDescription = "This metric monitors ec2 cpu utilization",
            ComparisonOperator = "GreaterThanUpperThreshold",
            EvaluationPeriods = 2,
            InsufficientDataActions = {},
            MetricQueries = 
            {
                new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
                {
                    Expression = "ANOMALY_DETECTION_BAND(m1)",
                    Id = "e1",
                    Label = "CPUUtilization (Expected)",
                    ReturnData = true,
                },
                new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryArgs
                {
                    Id = "m1",
                    Metric = new Aws.CloudWatch.Inputs.MetricAlarmMetricQueryMetricArgs
                    {
                        Dimensions = 
                        {
                            { "InstanceId", "i-abc123" },
                        },
                        MetricName = "CPUUtilization",
                        Namespace = "AWS/EC2",
                        Period = 120,
                        Stat = "Average",
                        Unit = "Count",
                    },
                    ReturnData = true,
                },
            },
            ThresholdMetricId = "e1",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sns"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudwatch.NewMetricAlarm(ctx, "xxAnomalyDetection", &cloudwatch.MetricAlarmArgs{
			AlarmDescription:        pulumi.String("This metric monitors ec2 cpu utilization"),
			ComparisonOperator:      pulumi.String("GreaterThanUpperThreshold"),
			EvaluationPeriods:       pulumi.Int(2),
			InsufficientDataActions: pulumi.AnyArray{},
			MetricQueries: cloudwatch.MetricAlarmMetricQueryArray{
				&cloudwatch.MetricAlarmMetricQueryArgs{
					Expression: pulumi.String("ANOMALY_DETECTION_BAND(m1)"),
					Id:         pulumi.String("e1"),
					Label:      pulumi.String("CPUUtilization (Expected)"),
					ReturnData: pulumi.Bool(true),
				},
				&cloudwatch.MetricAlarmMetricQueryArgs{
					Id: pulumi.String("m1"),
					Metric: &cloudwatch.MetricAlarmMetricQueryMetricArgs{
						Dimensions: pulumi.StringMap{
							"InstanceId": pulumi.String("i-abc123"),
						},
						MetricName: pulumi.String("CPUUtilization"),
						Namespace:  pulumi.String("AWS/EC2"),
						Period:     pulumi.Int(120),
						Stat:       pulumi.String("Average"),
						Unit:       pulumi.String("Count"),
					},
					ReturnData: pulumi.Bool(true),
				},
			},
			ThresholdMetricId: pulumi.String("e1"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

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()        
            .alarmDescription("This metric monitors ec2 cpu utilization")
            .comparisonOperator("GreaterThanUpperThreshold")
            .evaluationPeriods("2")
            .insufficientDataActions()
            .metricQueries(            
                MetricAlarmMetricQueryArgs.builder()
                    .expression("ANOMALY_DETECTION_BAND(m1)")
                    .id("e1")
                    .label("CPUUtilization (Expected)")
                    .returnData("true")
                    .build(),
                MetricAlarmMetricQueryArgs.builder()
                    .id("m1")
                    .metric(MetricAlarmMetricQueryMetricArgs.builder()
                        .dimensions(Map.of("InstanceId", "i-abc123"))
                        .metricName("CPUUtilization")
                        .namespace("AWS/EC2")
                        .period("120")
                        .stat("Average")
                        .unit("Count")
                        .build())
                    .returnData("true")
                    .build())
            .thresholdMetricId("e1")
            .build());

    }
}
resources:
  xxAnomalyDetection:
    type: aws:cloudwatch:MetricAlarm
    properties:
      alarmDescription: This metric monitors ec2 cpu utilization
      comparisonOperator: GreaterThanUpperThreshold
      evaluationPeriods: 2
      insufficientDataActions: []
      metricQueries:
        - expression: ANOMALY_DETECTION_BAND(m1)
          id: e1
          label: CPUUtilization (Expected)
          returnData: true
        - id: m1
          metric:
            dimensions:
              InstanceId: i-abc123
            metricName: CPUUtilization
            namespace: AWS/EC2
            period: 120
            stat: Average
            unit: Count
          returnData: true
      thresholdMetricId: e1

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("nlbHealthyhosts", {
    comparisonOperator: "LessThanThreshold",
    evaluationPeriods: 1,
    metricName: "HealthyHostCount",
    namespace: "AWS/NetworkELB",
    period: 60,
    statistic: "Average",
    threshold: _var.logstash_servers_count,
    alarmDescription: "Number of healthy nodes in Target Group",
    actionsEnabled: true,
    alarmActions: [aws_sns_topic.sns.arn],
    okActions: [aws_sns_topic.sns.arn],
    dimensions: {
        TargetGroup: aws_lb_target_group["lb-tg"].arn_suffix,
        LoadBalancer: aws_lb.lb.arn_suffix,
    },
});
import pulumi
import pulumi_aws as aws

nlb_healthyhosts = aws.cloudwatch.MetricAlarm("nlbHealthyhosts",
    comparison_operator="LessThanThreshold",
    evaluation_periods=1,
    metric_name="HealthyHostCount",
    namespace="AWS/NetworkELB",
    period=60,
    statistic="Average",
    threshold=var["logstash_servers_count"],
    alarm_description="Number of healthy nodes in Target Group",
    actions_enabled=True,
    alarm_actions=[aws_sns_topic["sns"]["arn"]],
    ok_actions=[aws_sns_topic["sns"]["arn"]],
    dimensions={
        "TargetGroup": aws_lb_target_group["lb-tg"]["arn_suffix"],
        "LoadBalancer": aws_lb["lb"]["arn_suffix"],
    })
using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var nlbHealthyhosts = new Aws.CloudWatch.MetricAlarm("nlbHealthyhosts", new Aws.CloudWatch.MetricAlarmArgs
        {
            ComparisonOperator = "LessThanThreshold",
            EvaluationPeriods = 1,
            MetricName = "HealthyHostCount",
            Namespace = "AWS/NetworkELB",
            Period = 60,
            Statistic = "Average",
            Threshold = @var.Logstash_servers_count,
            AlarmDescription = "Number of healthy nodes in Target Group",
            ActionsEnabled = true,
            AlarmActions = 
            {
                aws_sns_topic.Sns.Arn,
            },
            OkActions = 
            {
                aws_sns_topic.Sns.Arn,
            },
            Dimensions = 
            {
                { "TargetGroup", aws_lb_target_group.Lb_tg.Arn_suffix },
                { "LoadBalancer", aws_lb.Lb.Arn_suffix },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/sns"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := cloudwatch.NewMetricAlarm(ctx, "nlbHealthyhosts", &cloudwatch.MetricAlarmArgs{
			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(_var.Logstash_servers_count),
			AlarmDescription:   pulumi.String("Number of healthy nodes in Target Group"),
			ActionsEnabled:     pulumi.Bool(true),
			AlarmActions: pulumi.AnyArray{
				pulumi.Any(aws_sns_topic.Sns.Arn),
			},
			OkActions: pulumi.AnyArray{
				pulumi.Any(aws_sns_topic.Sns.Arn),
			},
			Dimensions: pulumi.StringMap{
				"TargetGroup":  pulumi.Any(aws_lb_target_group.Lb - tg.Arn_suffix),
				"LoadBalancer": pulumi.Any(aws_lb.Lb.Arn_suffix),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

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()        
            .comparisonOperator("LessThanThreshold")
            .evaluationPeriods("1")
            .metricName("HealthyHostCount")
            .namespace("AWS/NetworkELB")
            .period("60")
            .statistic("Average")
            .threshold(var_.logstash_servers_count())
            .alarmDescription("Number of healthy nodes in Target Group")
            .actionsEnabled("true")
            .alarmActions(aws_sns_topic.sns().arn())
            .okActions(aws_sns_topic.sns().arn())
            .dimensions(Map.ofEntries(
                Map.entry("TargetGroup", aws_lb_target_group.lb-tg().arn_suffix()),
                Map.entry("LoadBalancer", aws_lb.lb().arn_suffix())
            ))
            .build());

    }
}
resources:
  nlbHealthyhosts:
    type: aws:cloudwatch:MetricAlarm
    properties:
      comparisonOperator: LessThanThreshold
      evaluationPeriods: 1
      metricName: HealthyHostCount
      namespace: AWS/NetworkELB
      period: 60
      statistic: Average
      threshold: ${var.logstash_servers_count}
      alarmDescription: Number of healthy nodes in Target Group
      actionsEnabled: true
      alarmActions:
        - ${aws_sns_topic.sns.arn}
      okActions:
        - ${aws_sns_topic.sns.arn}
      dimensions:
        TargetGroup: ${aws_lb_target_group"lb-tg"[%!s(MISSING)].arn_suffix}
        LoadBalancer: ${aws_lb.lb.arn_suffix}

NOTE: You cannot create a metric alarm consisting of both statistic and extended_statistic parameters. You must choose one or the other

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var foobar = new Aws.CloudWatch.MetricAlarm("foobar", new Aws.CloudWatch.MetricAlarmArgs
        {
            AlarmDescription = "This metric monitors ec2 cpu utilization",
            ComparisonOperator = "GreaterThanOrEqualToThreshold",
            EvaluationPeriods = 2,
            InsufficientDataActions = {},
            MetricName = "CPUUtilization",
            Namespace = "AWS/EC2",
            Period = 120,
            Statistic = "Average",
            Threshold = 80,
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/cloudwatch"
	"github.com/pulumi/pulumi-aws/sdk/v5/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{
			AlarmDescription:        pulumi.String("This metric monitors ec2 cpu utilization"),
			ComparisonOperator:      pulumi.String("GreaterThanOrEqualToThreshold"),
			EvaluationPeriods:       pulumi.Int(2),
			InsufficientDataActions: pulumi.AnyArray{},
			MetricName:              pulumi.String("CPUUtilization"),
			Namespace:               pulumi.String("AWS/EC2"),
			Period:                  pulumi.Int(120),
			Statistic:               pulumi.String("Average"),
			Threshold:               pulumi.Float64(80),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

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()        
            .alarmDescription("This metric monitors ec2 cpu utilization")
            .comparisonOperator("GreaterThanOrEqualToThreshold")
            .evaluationPeriods("2")
            .insufficientDataActions()
            .metricName("CPUUtilization")
            .namespace("AWS/EC2")
            .period("120")
            .statistic("Average")
            .threshold("80")
            .build());

    }
}
import pulumi
import pulumi_aws as aws

foobar = aws.cloudwatch.MetricAlarm("foobar",
    alarm_description="This metric monitors ec2 cpu utilization",
    comparison_operator="GreaterThanOrEqualToThreshold",
    evaluation_periods=2,
    insufficient_data_actions=[],
    metric_name="CPUUtilization",
    namespace="AWS/EC2",
    period=120,
    statistic="Average",
    threshold=80)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const foobar = new aws.cloudwatch.MetricAlarm("foobar", {
    alarmDescription: "This metric monitors ec2 cpu utilization",
    comparisonOperator: "GreaterThanOrEqualToThreshold",
    evaluationPeriods: 2,
    insufficientDataActions: [],
    metricName: "CPUUtilization",
    namespace: "AWS/EC2",
    period: 120,
    statistic: "Average",
    threshold: 80,
});
resources:
  foobar:
    type: aws:cloudwatch:MetricAlarm
    properties:
      alarmDescription: This metric monitors ec2 cpu utilization
      comparisonOperator: GreaterThanOrEqualToThreshold
      evaluationPeriods: 2
      insufficientDataActions: []
      metricName: CPUUtilization
      namespace: AWS/EC2
      period: 120
      statistic: Average
      threshold: 80

Create a MetricAlarm Resource

new MetricAlarm(name: string, args: MetricAlarmArgs, opts?: CustomResourceOptions);
@overload
def MetricAlarm(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                actions_enabled: Optional[bool] = None,
                alarm_actions: Optional[Sequence[str]] = None,
                alarm_description: 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,
                threshold: Optional[float] = None,
                threshold_metric_id: Optional[str] = None,
                treat_missing_data: Optional[str] = None,
                unit: Optional[str] = None)
@overload
def MetricAlarm(resource_name: str,
                args: MetricAlarmArgs,
                opts: Optional[ResourceOptions] = 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.

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.

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

The MetricAlarm resource accepts the following input properties:

ComparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

EvaluationPeriods int

The number of periods over which data is compared to the specified threshold.

ActionsEnabled bool

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

AlarmActions 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).

AlarmDescription string

The description for the alarm.

DatapointsToAlarm int

The number of datapoints that must be breaching to trigger the alarm.

Dimensions Dictionary<string, string>

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

EvaluateLowSampleCountPercentiles string

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 specify evaluate 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, and evaluate.

ExtendedStatistic string

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

InsufficientDataActions List<string>

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).

MetricName string

The name for this metric. See docs for supported metrics.

MetricQueries List<MetricAlarmMetricQueryArgs>

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

OkActions 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 stat is applied.

Statistic string

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

Tags 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.

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.

ThresholdMetricId string

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

TreatMissingData string

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

Unit string

The unit for this metric.

ComparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

EvaluationPeriods int

The number of periods over which data is compared to the specified threshold.

ActionsEnabled bool

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

AlarmActions []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).

AlarmDescription string

The description for the alarm.

DatapointsToAlarm int

The number of datapoints that must be breaching to trigger the alarm.

Dimensions map[string]string

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

EvaluateLowSampleCountPercentiles string

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 specify evaluate 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, and evaluate.

ExtendedStatistic string

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

InsufficientDataActions []interface{}

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).

MetricName string

The name for this metric. See docs for supported metrics.

MetricQueries []MetricAlarmMetricQueryArgs

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

OkActions []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 stat is applied.

Statistic string

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

Tags 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.

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.

ThresholdMetricId string

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

TreatMissingData string

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

Unit string

The unit for this metric.

comparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

evaluationPeriods Integer

The number of periods over which data is compared to the specified threshold.

actionsEnabled Boolean

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

alarmActions 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).

alarmDescription String

The description for the alarm.

datapointsToAlarm Integer

The number of datapoints that must be breaching to trigger the alarm.

dimensions Map<String,String>

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluateLowSampleCountPercentiles String

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 specify evaluate 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, and evaluate.

extendedStatistic String

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficientDataActions List<String>

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).

metricName String

The name for this metric. See docs for supported metrics.

metricQueries List<MetricAlarmMetricQueryArgs>

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

okActions 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 stat is applied.

statistic String

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags 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.

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.

thresholdMetricId String

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

treatMissingData String

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit String

The unit for this metric.

comparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

evaluationPeriods number

The number of periods over which data is compared to the specified threshold.

actionsEnabled boolean

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

alarmActions (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).

alarmDescription string

The description for the alarm.

datapointsToAlarm number

The number of datapoints that must be breaching to trigger the alarm.

dimensions {[key: string]: string}

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluateLowSampleCountPercentiles string

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 specify evaluate 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, and evaluate.

extendedStatistic string

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficientDataActions (string | Topic)[]

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).

metricName string

The name for this metric. See docs for supported metrics.

metricQueries MetricAlarmMetricQueryArgs[]

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

okActions (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 stat is applied.

statistic string

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags {[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.

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.

thresholdMetricId string

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

treatMissingData string

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit string

The unit for this 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold 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_alarm int

The number of datapoints that must be breaching to trigger the alarm.

dimensions Mapping[str, str]

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluate_low_sample_count_percentiles str

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 specify evaluate 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, and evaluate.

extended_statistic str

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficient_data_actions Sequence[str]

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 this metric. See docs for supported metrics.

metric_queries Sequence[MetricAlarmMetricQueryArgs]

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 this 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 stat is applied.

statistic str

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags 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.

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_id str

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_data str

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit str

The unit for this metric.

comparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

evaluationPeriods Number

The number of periods over which data is compared to the specified threshold.

actionsEnabled Boolean

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

alarmActions 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).

alarmDescription String

The description for the alarm.

datapointsToAlarm Number

The number of datapoints that must be breaching to trigger the alarm.

dimensions Map<String>

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluateLowSampleCountPercentiles String

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 specify evaluate 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, and evaluate.

extendedStatistic String

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficientDataActions List<String | >

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).

metricName String

The name for this metric. See docs for supported metrics.

metricQueries 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 this metric. See docs for the list of namespaces. See docs for supported metrics.

okActions 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 stat is applied.

statistic String

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags 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.

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.

thresholdMetricId String

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

treatMissingData String

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit String

The unit for this metric.

Outputs

All input properties are implicitly available as output properties. Additionally, the MetricAlarm resource produces the following output properties:

Arn string

The ARN of the CloudWatch Metric Alarm.

Id string

The provider-assigned unique ID for this managed resource.

TagsAll Dictionary<string, string>

A map of tags assigned to the resource, including those inherited from the provider .

Arn string

The ARN of the CloudWatch Metric Alarm.

Id string

The provider-assigned unique ID for this managed resource.

TagsAll map[string]string

A map of tags assigned to the resource, including those inherited from the provider .

arn String

The ARN of the CloudWatch Metric Alarm.

id String

The provider-assigned unique ID for this managed resource.

tagsAll Map<String,String>

A map of tags assigned to the resource, including those inherited from the provider .

arn string

The ARN of the CloudWatch Metric Alarm.

id string

The provider-assigned unique ID for this managed resource.

tagsAll {[key: string]: string}

A map of tags assigned to the resource, including those inherited from the provider .

arn str

The ARN of the CloudWatch Metric Alarm.

id str

The provider-assigned unique ID for this managed resource.

tags_all Mapping[str, str]

A map of tags assigned to the resource, including those inherited from the provider .

arn String

The ARN of the CloudWatch Metric Alarm.

id String

The provider-assigned unique ID for this managed resource.

tagsAll Map<String>

A map of tags assigned to the resource, including those inherited from the provider .

Look up an 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.
The following state arguments are supported:
ActionsEnabled bool

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

AlarmActions 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).

AlarmDescription string

The description for the alarm.

Arn string

The ARN of the CloudWatch Metric Alarm.

ComparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

DatapointsToAlarm int

The number of datapoints that must be breaching to trigger the alarm.

Dimensions Dictionary<string, string>

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

EvaluateLowSampleCountPercentiles string

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 specify evaluate 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, and evaluate.

EvaluationPeriods int

The number of periods over which data is compared to the specified threshold.

ExtendedStatistic string

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

InsufficientDataActions List<string>

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).

MetricName string

The name for this metric. See docs for supported metrics.

MetricQueries List<MetricAlarmMetricQueryArgs>

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

OkActions 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 stat is applied.

Statistic string

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

Tags 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.

TagsAll Dictionary<string, string>

A map of tags assigned to the resource, including those inherited from the provider .

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.

ThresholdMetricId string

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

TreatMissingData string

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

Unit string

The unit for this metric.

ActionsEnabled bool

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

AlarmActions []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).

AlarmDescription string

The description for the alarm.

Arn string

The ARN of the CloudWatch Metric Alarm.

ComparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

DatapointsToAlarm int

The number of datapoints that must be breaching to trigger the alarm.

Dimensions map[string]string

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

EvaluateLowSampleCountPercentiles string

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 specify evaluate 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, and evaluate.

EvaluationPeriods int

The number of periods over which data is compared to the specified threshold.

ExtendedStatistic string

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

InsufficientDataActions []interface{}

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).

MetricName string

The name for this metric. See docs for supported metrics.

MetricQueries []MetricAlarmMetricQueryArgs

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

OkActions []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 stat is applied.

Statistic string

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

Tags 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.

TagsAll map[string]string

A map of tags assigned to the resource, including those inherited from the provider .

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.

ThresholdMetricId string

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

TreatMissingData string

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

Unit string

The unit for this metric.

actionsEnabled Boolean

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

alarmActions 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).

alarmDescription String

The description for the alarm.

arn String

The ARN of the CloudWatch Metric Alarm.

comparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

datapointsToAlarm Integer

The number of datapoints that must be breaching to trigger the alarm.

dimensions Map<String,String>

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluateLowSampleCountPercentiles String

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 specify evaluate 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, and evaluate.

evaluationPeriods Integer

The number of periods over which data is compared to the specified threshold.

extendedStatistic String

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficientDataActions List<String>

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).

metricName String

The name for this metric. See docs for supported metrics.

metricQueries List<MetricAlarmMetricQueryArgs>

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

okActions 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 stat is applied.

statistic String

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags 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.

tagsAll Map<String,String>

A map of tags assigned to the resource, including those inherited from the provider .

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.

thresholdMetricId String

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

treatMissingData String

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit String

The unit for this metric.

actionsEnabled boolean

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

alarmActions (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).

alarmDescription string

The description for the alarm.

arn string

The ARN of the CloudWatch Metric Alarm.

comparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

datapointsToAlarm number

The number of datapoints that must be breaching to trigger the alarm.

dimensions {[key: string]: string}

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluateLowSampleCountPercentiles string

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 specify evaluate 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, and evaluate.

evaluationPeriods number

The number of periods over which data is compared to the specified threshold.

extendedStatistic string

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficientDataActions (string | Topic)[]

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).

metricName string

The name for this metric. See docs for supported metrics.

metricQueries MetricAlarmMetricQueryArgs[]

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 this metric. See docs for the list of namespaces. See docs for supported metrics.

okActions (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 stat is applied.

statistic string

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags {[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.

tagsAll {[key: string]: string}

A map of tags assigned to the resource, including those inherited from the provider .

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.

thresholdMetricId string

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

treatMissingData string

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit string

The unit for this 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

datapoints_to_alarm int

The number of datapoints that must be breaching to trigger the alarm.

dimensions Mapping[str, str]

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluate_low_sample_count_percentiles str

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 specify evaluate 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, and evaluate.

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_actions Sequence[str]

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 this metric. See docs for supported metrics.

metric_queries Sequence[MetricAlarmMetricQueryArgs]

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 this 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 stat is applied.

statistic str

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags 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.

tags_all Mapping[str, str]

A map of tags assigned to the resource, including those inherited from the provider .

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_id str

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_data str

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit str

The unit for this metric.

actionsEnabled Boolean

Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to true.

alarmActions 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).

alarmDescription String

The description for the alarm.

arn String

The ARN of the CloudWatch Metric Alarm.

comparisonOperator 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 values LessThanLowerOrGreaterThanUpperThreshold, LessThanLowerThreshold, and GreaterThanUpperThreshold are used only for alarms based on anomaly detection models.

datapointsToAlarm Number

The number of datapoints that must be breaching to trigger the alarm.

dimensions Map<String>

The dimensions for this metric. For the list of available dimensions see the AWS documentation here.

evaluateLowSampleCountPercentiles String

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 specify evaluate 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, and evaluate.

evaluationPeriods Number

The number of periods over which data is compared to the specified threshold.

extendedStatistic String

The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.

insufficientDataActions List<String | >

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).

metricName String

The name for this metric. See docs for supported metrics.

metricQueries 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 this metric. See docs for the list of namespaces. See docs for supported metrics.

okActions 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 stat is applied.

statistic String

The statistic to apply to the alarm's associated metric. Either of the following is supported: SampleCount, Average, Sum, Minimum, Maximum

tags 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.

tagsAll Map<String>

A map of tags assigned to the resource, including those inherited from the provider .

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.

thresholdMetricId String

If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function.

treatMissingData String

Sets how this alarm is to handle missing data points. The following values are supported: missing, ignore, breaching and notBreaching. Defaults to missing.

unit String

The unit for this metric.

Supporting Types

MetricAlarmMetricQuery

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.

AccountId 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 MetricAlarmMetricQueryMetric

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.

ReturnData bool

Specify exactly one metric_query to be true to use that metric_query result as the alarm.

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.

AccountId 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 MetricAlarmMetricQueryMetric

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.

ReturnData bool

Specify exactly one metric_query to be true to use that metric_query result as the alarm.

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.

accountId 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 MetricAlarmMetricQueryMetric

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.

returnData Boolean

Specify exactly one metric_query to be true to use that metric_query result as the alarm.

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.

accountId 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 MetricAlarmMetricQueryMetric

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.

returnData boolean

Specify exactly one metric_query to be true to use that metric_query result as the alarm.

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 MetricAlarmMetricQueryMetric

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.

return_data bool

Specify exactly one metric_query to be true to use that metric_query result as the alarm.

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.

accountId 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.

returnData Boolean

Specify exactly one metric_query to be true to use that metric_query result as the alarm.

MetricAlarmMetricQueryMetric

MetricName string

The name for this metric. See docs for supported metrics.

Period int

The period in seconds over which the specified stat is applied.

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.

MetricName string

The name for this metric. See docs for supported metrics.

Period int

The period in seconds over which the specified stat is applied.

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.

metricName String

The name for this metric. See docs for supported metrics.

period Integer

The period in seconds over which the specified stat is applied.

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.

metricName string

The name for this metric. See docs for supported metrics.

period number

The period in seconds over which the specified stat is applied.

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

The period in seconds over which the specified stat is applied.

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.

metricName String

The name for this metric. See docs for supported metrics.

period Number

The period in seconds over which the specified stat is applied.

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

CloudWatch Metric Alarm can be imported using the alarm_name, e.g.,

 $ pulumi import aws:cloudwatch/metricAlarm:MetricAlarm test alarm-12345

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.