github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/website/source/docs/providers/aws/r/cloudwatch_metric_alarm.html.markdown (about)

     1  ---
     2  layout: "aws"
     3  page_title: "AWS: cloudwatch_metric_alarm"
     4  sidebar_current: "docs-aws-resource-cloudwatch-metric-alarm"
     5  description: |-
     6    Provides an AutoScaling Scaling Group resource.
     7  ---
     8  
     9  # aws\_cloudwatch\_metric\_alarm
    10  
    11  Provides a CloudWatch Metric Alarm resource.
    12  
    13  ## Example Usage
    14  
    15  ```hcl
    16  resource "aws_cloudwatch_metric_alarm" "foobar" {
    17    alarm_name                = "terraform-test-foobar5"
    18    comparison_operator       = "GreaterThanOrEqualToThreshold"
    19    evaluation_periods        = "2"
    20    metric_name               = "CPUUtilization"
    21    namespace                 = "AWS/EC2"
    22    period                    = "120"
    23    statistic                 = "Average"
    24    threshold                 = "80"
    25    alarm_description         = "This metric monitors ec2 cpu utilization"
    26    insufficient_data_actions = []
    27  }
    28  ```
    29  
    30  ## Example in Conjunction with Scaling Policies
    31  
    32  ```hcl
    33  resource "aws_autoscaling_policy" "bat" {
    34    name                   = "foobar3-terraform-test"
    35    scaling_adjustment     = 4
    36    adjustment_type        = "ChangeInCapacity"
    37    cooldown               = 300
    38    autoscaling_group_name = "${aws_autoscaling_group.bar.name}"
    39  }
    40  
    41  resource "aws_cloudwatch_metric_alarm" "bat" {
    42    alarm_name          = "terraform-test-foobar5"
    43    comparison_operator = "GreaterThanOrEqualToThreshold"
    44    evaluation_periods  = "2"
    45    metric_name         = "CPUUtilization"
    46    namespace           = "AWS/EC2"
    47    period              = "120"
    48    statistic           = "Average"
    49    threshold           = "80"
    50  
    51    dimensions {
    52      AutoScalingGroupName = "${aws_autoscaling_group.bar.name}"
    53    }
    54  
    55    alarm_description = "This metric monitors ec2 cpu utilization"
    56    alarm_actions     = ["${aws_autoscaling_policy.bat.arn}"]
    57  }
    58  ```
    59  
    60  ~> **NOTE:**  You cannot create a metric alarm consisting of both `statistic` and `extended_statistic` parameters.
    61  You must choose one or the other
    62  
    63  ## Argument Reference
    64  
    65  See [related part of AWS Docs](https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html)
    66  for details about valid values.
    67  
    68  The following arguments are supported:
    69  
    70  * `alarm_name` - (Required) The descriptive name for the alarm. This name must be unique within the user's AWS account
    71  * `comparison_operator` - (Required) 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`.
    72  * `evaluation_periods` - (Required) The number of periods over which data is compared to the specified threshold.
    73  * `metric_name` - (Required) The name for the alarm's associated metric.
    74    See docs for [supported metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html).
    75  * `namespace` - (Required) The namespace for the alarm's associated metric. See docs for the [list of namespaces](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/aws-namespaces.html).
    76    See docs for [supported metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html).
    77  * `period` - (Required) The period in seconds over which the specified `statistic` is applied.
    78  * `statistic` - (Optional) The statistic to apply to the alarm's associated metric.
    79     Either of the following is supported: `SampleCount`, `Average`, `Sum`, `Minimum`, `Maximum`
    80  * `threshold` - (Required) The value against which the specified statistic is compared.
    81  * `actions_enabled` - (Optional) Indicates whether or not actions should be executed during any changes to the alarm's state. Defaults to `true`.
    82  * `alarm_actions` - (Optional) 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 Number (ARN).
    83  * `alarm_description` - (Optional) The description for the alarm.
    84  * `dimensions` - (Optional) The dimensions for the alarm's associated metric.  For the list of available dimensions see the AWS documentation [here](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html).
    85  * `insufficient_data_actions` - (Optional) 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 Number (ARN).
    86  * `ok_actions` - (Optional) 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 Number (ARN).
    87  * `unit` - (Optional) The unit for the alarm's associated metric.
    88  * `extended_statistic` - (Optional) The percentile statistic for the metric associated with the alarm. Specify a value between p0.0 and p100.
    89  * `treat_missing_data` - (Optional) Sets how this alarm is to handle missing data points. The following values are supported: `missing`, `ignore`, `breaching` and `notBreaching`. Defaults to `missing`.
    90  * `evaluate_low_sample_count_percentiles` - (Optional) Used only for alarms
    91  based on percentiles. If you specify `ignore`, the alarm state will not
    92  change during periods with too few data points to be statistically significant.
    93  If you specify `evaluate` or omit this parameter, the alarm will always be
    94  evaluated and possibly change state no matter how many data points are available.
    95  The following values are supported: `ignore`, and `evaluate`.
    96  
    97  ## Attributes Reference
    98  
    99  The following attributes are exported:
   100  
   101  * `id` - The ID of the health check
   102  
   103  ## Import
   104  
   105  Cloud Metric Alarms can be imported using the `alarm_name`, e.g.
   106  
   107  ```
   108  $ terraform import aws_cloudwatch_metric_alarm.test alarm-12345
   109  ```