Show / Hide Table of Contents

Class Alarm

An alarm on a CloudWatch metric.

Inheritance
System.Object
Resource
AlarmBase
Alarm
Implements
IAlarm
IAlarmRule
IResource
Constructs.IConstruct
Constructs.IDependable
Inherited Members
AlarmBase.AddInsufficientDataAction(IAlarmAction[])
AlarmBase.AddOkAction(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
Syntax (vb)
Public Class Alarm
    Inherits AlarmBase
    Implements IAlarm, IAlarmRule, IResource
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(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

Alarm(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Alarm(Construct, String, IAlarmProps)

Properties

AlarmArn

ARN of this alarm.

AlarmName

Name of this alarm.

Metric

The metric object this alarm was based on.

Methods

AddAlarmAction(IAlarmAction[])

Trigger this action if the alarm fires.

FromAlarmArn(Construct, String, String)

Import an existing CloudWatch alarm provided an ARN.

ToAnnotation()

Turn this alarm into a horizontal annotation.

Constructors

Alarm(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected Alarm(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

Alarm(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected Alarm(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Alarm(Construct, String, IAlarmProps)

public Alarm(Construct scope, string id, IAlarmProps props)
Parameters
scope Constructs.Construct
id System.String
props IAlarmProps

Properties

AlarmArn

ARN of this alarm.

public override string AlarmArn { get; }
Property Value

System.String

Overrides
AlarmBase.AlarmArn
Remarks

Attribute: true

AlarmName

Name of this alarm.

public override string AlarmName { get; }
Property Value

System.String

Overrides
AlarmBase.AlarmName
Remarks

Attribute: true

Metric

The metric object this alarm was based on.

public virtual IMetric Metric { get; }
Property Value

IMetric

Methods

AddAlarmAction(IAlarmAction[])

Trigger this action if the alarm fires.

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

Typically the ARN of an SNS topic or ARN of an AutoScaling policy.

FromAlarmArn(Construct, String, String)

Import an existing CloudWatch alarm provided an ARN.

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

The parent creating construct (usually this).

id System.String

The construct's name.

alarmArn System.String

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

Returns

IAlarm

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