{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://schemas.apis.io/cloudwatch/cloudwatch-alarm-schema.json", "title": "Amazon CloudWatch Alarm", "description": "Schema for an Amazon CloudWatch alarm resource, representing a watch over a single CloudWatch metric or the result of a math expression based on CloudWatch metrics. The alarm triggers actions when the metric or expression value breaches a defined threshold over a specified number of evaluation periods.", "type": "object", "required": [ "AlarmName", "ComparisonOperator", "EvaluationPeriods" ], "properties": { "AlarmName": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The name of the alarm. This name must be unique within the Region and within the AWS account. The maximum length is 255 characters." }, "AlarmArn": { "type": "string", "minLength": 1, "maxLength": 1600, "pattern": "^arn:aws[a-zA-Z-]*:cloudwatch:[a-z0-9-]+:[0-9]{12}:alarm:.+$", "description": "The Amazon Resource Name (ARN) of the alarm, in the format arn:aws:cloudwatch:region:account-id:alarm:alarm-name." }, "AlarmDescription": { "type": "string", "maxLength": 1024, "description": "The description for the alarm. Up to 1024 characters." }, "AlarmConfigurationUpdatedTimestamp": { "type": "string", "format": "date-time", "description": "The time stamp of the last update to the alarm configuration, in ISO 8601 format." }, "ActionsEnabled": { "type": "boolean", "default": true, "description": "Indicates whether actions should be executed during any changes to the alarm state. When set to false, the alarm state changes but no actions are executed." }, "OKActions": { "type": "array", "items": { "type": "string", "maxLength": 1024, "description": "An ARN identifying an action to perform when the alarm transitions to the OK state. Supported resources include Amazon SNS topics, Auto Scaling policies, and Amazon EC2 actions." }, "maxItems": 5, "description": "The actions to execute when this alarm transitions to the OK state from any other state. Each action is specified as an ARN. A maximum of 5 actions are allowed." }, "AlarmActions": { "type": "array", "items": { "type": "string", "maxLength": 1024, "description": "An ARN identifying an action to perform when the alarm transitions to the ALARM state. Supported resources include Amazon SNS topics, Auto Scaling policies, Amazon EC2 actions, and Systems Manager OpsItems." }, "maxItems": 5, "description": "The actions to execute when this alarm transitions to the ALARM state from any other state. Each action is specified as an ARN. A maximum of 5 actions are allowed." }, "InsufficientDataActions": { "type": "array", "items": { "type": "string", "maxLength": 1024, "description": "An ARN identifying an action to perform when the alarm transitions to the INSUFFICIENT_DATA state." }, "maxItems": 5, "description": "The actions to execute when this alarm transitions to the INSUFFICIENT_DATA state from any other state. Each action is specified as an ARN. A maximum of 5 actions are allowed." }, "StateValue": { "type": "string", "enum": [ "OK", "ALARM", "INSUFFICIENT_DATA" ], "description": "The current state value for the alarm. OK indicates the metric or expression is within the defined threshold. ALARM indicates the metric or expression is outside of the defined threshold. INSUFFICIENT_DATA indicates there is not enough data to determine the alarm state." }, "StateReason": { "type": "string", "maxLength": 1023, "description": "An explanation for the alarm state, in text format. Provides a human-readable explanation of why the alarm is in its current state." }, "StateReasonData": { "type": "string", "maxLength": 4000, "description": "An explanation for the alarm state, in JSON format. Contains machine-readable data about the evaluation that led to the current alarm state." }, "StateUpdatedTimestamp": { "type": "string", "format": "date-time", "description": "The time stamp of the last update to the alarm's StateValue or StateReasonData, in ISO 8601 format." }, "StateTransitionedTimestamp": { "type": "string", "format": "date-time", "description": "The date and time that the alarm's StateValue most recently changed, in ISO 8601 format." }, "MetricName": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The name of the metric associated with the alarm, if this is a single-metric alarm." }, "Namespace": { "type": "string", "minLength": 1, "maxLength": 255, "pattern": "[^:].*", "description": "The namespace of the metric associated with the alarm. Namespaces that begin with AWS/ are reserved for AWS services." }, "Statistic": { "type": "string", "enum": [ "SampleCount", "Average", "Sum", "Minimum", "Maximum" ], "description": "The statistic for the metric specified in MetricName, other than percentile." }, "ExtendedStatistic": { "type": "string", "pattern": "^p(\\d{1,2}(\\.\\d{0,2})?|100)$", "description": "The percentile statistic for the metric specified in MetricName. Specify a value between p0.0 and p100." }, "Dimensions": { "type": "array", "items": { "$ref": "#/$defs/Dimension" }, "maxItems": 30, "description": "The dimensions for the metric specified in MetricName. A maximum of 30 dimensions are allowed per metric." }, "Period": { "type": "integer", "minimum": 1, "description": "The length, in seconds, used each time the metric specified in MetricName is evaluated. Valid values are 10, 30, and any multiple of 60. For high-resolution metrics, the period can be 10 or 30 seconds." }, "Unit": { "type": "string", "enum": [ "Seconds", "Microseconds", "Milliseconds", "Bytes", "Kilobytes", "Megabytes", "Gigabytes", "Terabytes", "Bits", "Kilobits", "Megabits", "Gigabits", "Terabits", "Percent", "Count", "Bytes/Second", "Kilobytes/Second", "Megabytes/Second", "Gigabytes/Second", "Terabytes/Second", "Bits/Second", "Kilobits/Second", "Megabits/Second", "Gigabits/Second", "Terabits/Second", "Count/Second", "None" ], "description": "The unit of measure for the statistic. If you do not specify Unit, CloudWatch retrieves all unit types that have been published for the metric." }, "EvaluationPeriods": { "type": "integer", "minimum": 1, "description": "The number of periods over which data is compared to the specified threshold. An alarm is triggered only if enough periods breach the threshold according to DatapointsToAlarm." }, "DatapointsToAlarm": { "type": "integer", "minimum": 1, "description": "The number of data points that must be breaching to trigger the alarm. This is used only if you are setting an M out of N alarm. The value must be less than or equal to EvaluationPeriods." }, "Threshold": { "type": "number", "description": "The value against which the specified statistic is compared. This value is used with ComparisonOperator to determine if the alarm should transition to the ALARM state." }, "ComparisonOperator": { "type": "string", "enum": [ "GreaterThanOrEqualToThreshold", "GreaterThanThreshold", "LessThanThreshold", "LessThanOrEqualToThreshold", "LessThanLowerOrGreaterThanUpperThreshold", "LessThanLowerThreshold", "GreaterThanUpperThreshold" ], "description": "The arithmetic operation to use when comparing the specified statistic and threshold. The specified statistic value is used as the first operand. The anomaly-detection-specific operators are used with anomaly detection models." }, "TreatMissingData": { "type": "string", "enum": [ "breaching", "notBreaching", "ignore", "missing" ], "default": "missing", "description": "Sets how this alarm is to handle missing data points. breaching treats missing data as breaching the threshold. notBreaching treats missing data as being within the threshold. ignore maintains the current alarm state. missing is the default and treats the missing data point as missing." }, "EvaluateLowSampleCountPercentile": { "type": "string", "enum": [ "evaluate", "ignore" ], "description": "Used only for alarms based on percentile statistics. If ignore, the alarm state does not change during periods with too few data points to be statistically significant." }, "Metrics": { "type": "array", "items": { "$ref": "#/$defs/MetricDataQuery" }, "description": "An array of MetricDataQuery structures indicating the metrics to be returned and the math expressions to perform. Used for metric math expression-based alarms." }, "ThresholdMetricId": { "type": "string", "description": "If this is an alarm based on an anomaly detection model, make this value match the ID of the ANOMALY_DETECTION_BAND function." }, "Tags": { "type": "array", "items": { "$ref": "#/$defs/Tag" }, "description": "A list of key-value pairs to associate with the alarm. You can associate as many as 50 tags with an alarm." } }, "$defs": { "Dimension": { "type": "object", "required": [ "Name", "Value" ], "properties": { "Name": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The name of the dimension. Dimension names must contain only ASCII characters, must include at least one non-whitespace character, and cannot start with a colon (:)." }, "Value": { "type": "string", "minLength": 1, "maxLength": 1024, "description": "The value of the dimension. Dimension values must contain only ASCII characters and must include at least one non-whitespace character." } }, "description": "A dimension is a name/value pair that is part of the identity of a metric. Because dimensions are part of the unique identifier for a metric, whenever you add a unique name/value pair to one of your metrics, you are creating a new variation of that metric." }, "MetricDataQuery": { "type": "object", "required": [ "Id" ], "properties": { "Id": { "type": "string", "minLength": 1, "maxLength": 255, "pattern": "^[a-z][a-zA-Z0-9_]*$", "description": "A short name used to tie this object to the results in the response. Must be unique within a single request and must start with a lowercase letter." }, "MetricStat": { "$ref": "#/$defs/MetricStat" }, "Expression": { "type": "string", "minLength": 1, "maxLength": 2048, "description": "This field can contain a Metrics Insights query, or a metric math expression to be performed on the returned data." }, "Label": { "type": "string", "description": "A human-readable label for this metric or expression. This is especially useful when this is an expression, so that you know what the value represents." }, "ReturnData": { "type": "boolean", "default": true, "description": "When used in GetMetricData, indicates whether to return the timestamps and raw data values of this metric. When used in PutMetricAlarm, determines whether this expression result is used as the alarm value." }, "Period": { "type": "integer", "minimum": 1, "description": "The granularity, in seconds, of the returned data points. For metrics with regular resolution, a period can be as short as one minute (60 seconds). For high-resolution metrics, a period can be as short as 1 second." }, "AccountId": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The ID of the account where the metrics are located, if this is a cross-account alarm." } }, "description": "This structure is used in both GetMetricData and PutMetricAlarm. It defines which metric to return data for, or which math expression to evaluate." }, "MetricStat": { "type": "object", "required": [ "Metric", "Period", "Stat" ], "properties": { "Metric": { "$ref": "#/$defs/Metric" }, "Period": { "type": "integer", "minimum": 1, "description": "The granularity, in seconds, of the returned data points." }, "Stat": { "type": "string", "description": "The statistic to return. It can include any CloudWatch statistic or extended statistic." }, "Unit": { "type": "string", "description": "When you are using a Put operation, this defines what unit you want to use when storing the metric." } }, "description": "This structure defines the metric to be returned, along with the statistics, period, and units." }, "Metric": { "type": "object", "properties": { "Namespace": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The namespace of the metric." }, "MetricName": { "type": "string", "minLength": 1, "maxLength": 255, "description": "The name of the metric." }, "Dimensions": { "type": "array", "items": { "$ref": "#/$defs/Dimension" }, "maxItems": 30, "description": "The dimensions for the metric." } }, "description": "Represents a specific metric." }, "Tag": { "type": "object", "required": [ "Key", "Value" ], "properties": { "Key": { "type": "string", "minLength": 1, "maxLength": 128, "description": "A string that you can use to assign a value. The combination of tag keys and values can help you organize and categorize your resources." }, "Value": { "type": "string", "minLength": 0, "maxLength": 256, "description": "The value for the specified tag key." } }, "description": "A key-value pair associated with a CloudWatch resource." } }, "examples": [ { "AlarmName": "HighCPUAlarm", "AlarmDescription": "Alarm when CPU exceeds 80%", "ActionsEnabled": true, "AlarmActions": [ "arn:aws:sns:us-east-1:123456789012:my-topic" ], "MetricName": "CPUUtilization", "Namespace": "AWS/EC2", "Statistic": "Average", "Dimensions": [ { "Name": "InstanceId", "Value": "i-0123456789abcdef0" } ], "Period": 300, "EvaluationPeriods": 3, "DatapointsToAlarm": 2, "Threshold": 80.0, "ComparisonOperator": "GreaterThanThreshold", "TreatMissingData": "missing" } ] }