Show / Hide Table of Contents

Class Alarm

An alarm on a CloudWatch metric.

Inheritance
object
Resource
AlarmBase
Alarm
AnomalyDetectionAlarm
Implements
IAlarm
IAlarmRule
IResource
IConstruct
IDependable
Inherited Members
AlarmBase.AddInsufficientDataAction(params IAlarmAction[])
AlarmBase.AddOkAction(params IAlarmAction[])
AlarmBase.RenderAlarmRule()
AlarmBase.AlarmActionArns
AlarmBase.InsufficientDataActionArns
AlarmBase.OkActionArns
Resource.IsOwnedResource(IConstruct)
Resource.IsResource(IConstruct)
Resource.ApplyRemovalPolicy(RemovalPolicy)
Resource.GeneratePhysicalName()
Resource.GetResourceArnAttribute(string, IArnComponents)
Resource.GetResourceNameAttribute(string)
Resource.Env
Resource.PhysicalName
Resource.Stack
Namespace: Amazon.CDK.AWS.CloudWatch
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Alarm : AlarmBase, IAlarm, IAlarmRule, IResource, IConstruct, IDependable
Syntax (vb)
Public Class Alarm Inherits AlarmBase Implements IAlarm, IAlarmRule, IResource, IConstruct, IDependable
Remarks

ExampleMetadata: infused

Examples
using Amazon.CDK.AWS.CloudWatch;

            Alias alias;

            // or add alarms to an existing group
            Alias blueGreenAlias;

            var alarm = new Alarm(this, "Errors", new AlarmProps {
                ComparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD,
                Threshold = 1,
                EvaluationPeriods = 1,
                Metric = alias.MetricErrors()
            });
            var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
                Alias = alias,
                DeploymentConfig = LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
                Alarms = new [] { alarm }
            });
            deploymentGroup.AddAlarm(new Alarm(this, "BlueGreenErrors", new AlarmProps {
                ComparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD,
                Threshold = 1,
                EvaluationPeriods = 1,
                Metric = blueGreenAlias.MetricErrors()
            }));

Synopsis

Constructors

Alarm(Construct, string, IAlarmProps)

An alarm on a CloudWatch metric.

Properties

ANOMALY_DETECTION_NO_THRESHOLD

Conventional value for the threshold property when creating anomaly detection alarms.

AlarmArn

ARN of this alarm.

AlarmName

Name of this alarm.

Metric

The metric object this alarm was based on.

PROPERTY_INJECTION_ID

Uniquely identifies this class.

Methods

AddAlarmAction(params IAlarmAction[])

Trigger this action if the alarm fires.

FromAlarmArn(Construct, string, string)

Import an existing CloudWatch alarm provided an ARN.

FromAlarmName(Construct, string, string)

Import an existing CloudWatch alarm provided an Name.

ToAnnotation()

Turn this alarm into a horizontal annotation.

Constructors

Alarm(Construct, string, IAlarmProps)

An alarm on a CloudWatch metric.

public Alarm(Construct scope, string id, IAlarmProps props)
Parameters
scope Construct
id string
props IAlarmProps
Remarks

ExampleMetadata: infused

Examples
using Amazon.CDK.AWS.CloudWatch;

            Alias alias;

            // or add alarms to an existing group
            Alias blueGreenAlias;

            var alarm = new Alarm(this, "Errors", new AlarmProps {
                ComparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD,
                Threshold = 1,
                EvaluationPeriods = 1,
                Metric = alias.MetricErrors()
            });
            var deploymentGroup = new LambdaDeploymentGroup(this, "BlueGreenDeployment", new LambdaDeploymentGroupProps {
                Alias = alias,
                DeploymentConfig = LambdaDeploymentConfig.LINEAR_10PERCENT_EVERY_1MINUTE,
                Alarms = new [] { alarm }
            });
            deploymentGroup.AddAlarm(new Alarm(this, "BlueGreenErrors", new AlarmProps {
                ComparisonOperator = ComparisonOperator.GREATER_THAN_THRESHOLD,
                Threshold = 1,
                EvaluationPeriods = 1,
                Metric = blueGreenAlias.MetricErrors()
            }));

Properties

ANOMALY_DETECTION_NO_THRESHOLD

Conventional value for the threshold property when creating anomaly detection alarms.

public static double ANOMALY_DETECTION_NO_THRESHOLD { get; }
Property Value

double

Remarks

Anomaly detection alarms don't have numbered threshold. Instead, they have a dynamically calculated threshold based on the metric math expression that contains a metric expression.

The threshold property is required, but the value is ignored. This constant has the value 0, and has a symbolic name to indicate why the threshold is 0. You can use new AnomalyDetectionAlarm() to avoid having to pass the threshold property at all.

AlarmArn

ARN of this alarm.

public override string AlarmArn { get; }
Property Value

string

Overrides
AlarmBase.AlarmArn
Remarks

Attribute: true

AlarmName

Name of this alarm.

public override string AlarmName { get; }
Property Value

string

Overrides
AlarmBase.AlarmName
Remarks

Attribute: true

Metric

The metric object this alarm was based on.

public virtual IMetric Metric { get; }
Property Value

IMetric

Remarks

ExampleMetadata: infused

PROPERTY_INJECTION_ID

Uniquely identifies this class.

public static string PROPERTY_INJECTION_ID { get; }
Property Value

string

Remarks

ExampleMetadata: infused

Methods

AddAlarmAction(params IAlarmAction[])

Trigger this action if the alarm fires.

public override void AddAlarmAction(params IAlarmAction[] actions)
Parameters
actions IAlarmAction[]
Overrides
AlarmBase.AddAlarmAction(params IAlarmAction[])
Remarks

Typically SnsAction or AutoScalingAction.

FromAlarmArn(Construct, string, string)

Import an existing CloudWatch alarm provided an ARN.

public static IAlarm FromAlarmArn(Construct scope, string id, string alarmArn)
Parameters
scope Construct

The parent creating construct (usually this).

id string

The construct's name.

alarmArn string

Alarm ARN (i.e. arn:aws:cloudwatch:<region>:<account-id>:alarm:Foo).

Returns

IAlarm

Remarks

ExampleMetadata: infused

FromAlarmName(Construct, string, string)

Import an existing CloudWatch alarm provided an Name.

public static IAlarm FromAlarmName(Construct scope, string id, string alarmName)
Parameters
scope Construct

The parent creating construct (usually this).

id string

The construct's name.

alarmName string

Alarm Name.

Returns

IAlarm

Remarks

ExampleMetadata: infused

ToAnnotation()

Turn this alarm into a horizontal annotation.

public virtual IHorizontalAnnotation ToAnnotation()
Returns

IHorizontalAnnotation

Remarks

This is useful if you want to represent an Alarm in a non-AlarmWidget. An AlarmWidget can directly show an alarm, but it can only show a single alarm and no other metrics. Instead, you can convert the alarm to a HorizontalAnnotation and add it as an annotation to another graph.

This might be useful if:

    Implements

    IAlarm
    IAlarmRule
    IResource
    Constructs.IConstruct
    Constructs.IDependable
    Back to top Generated by DocFX