Class Alarm
An alarm on a CloudWatch metric.
Inherited Members
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. |
FromAlarmName(Construct, String, String) | Import an existing CloudWatch alarm provided an Name. |
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
Remarks
Attribute: true
AlarmName
Name of this alarm.
public override string AlarmName { get; }
Property Value
System.String
Overrides
Remarks
Attribute: true
Metric
The metric object this alarm was based on.
public virtual IMetric Metric { get; }
Property Value
Methods
AddAlarmAction(IAlarmAction[])
Trigger this action if the alarm fires.
public override void AddAlarmAction(params IAlarmAction[] actions)
Parameters
- actions IAlarmAction[]
Overrides
Remarks
Typically SnsAcion 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 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
FromAlarmName(Construct, String, String)
Import an existing CloudWatch alarm provided an Name.
public static IAlarm FromAlarmName(Construct scope, string id, string alarmName)
Parameters
- scope Constructs.Construct
The parent creating construct (usually
this
).- id System.String
The construct's name.
- alarmName System.String
Alarm Name.
Returns
ToAnnotation()
Turn this alarm into a horizontal annotation.
public virtual IHorizontalAnnotation ToAnnotation()
Returns
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: