UNPKG

4.86 kBTypeScriptView Raw
1import { Construct } from 'constructs';
2import { IAlarmAction } from './alarm-action';
3import { AlarmBase, IAlarm } from './alarm-base';
4import { HorizontalAnnotation } from './graph';
5import { CreateAlarmOptions } from './metric';
6import { IMetric } from './metric-types';
7/**
8 * Properties for Alarms
9 */
10export interface AlarmProps extends CreateAlarmOptions {
11 /**
12 * The metric to add the alarm on
13 *
14 * Metric objects can be obtained from most resources, or you can construct
15 * custom Metric objects by instantiating one.
16 */
17 readonly metric: IMetric;
18}
19/**
20 * Comparison operator for evaluating alarms
21 */
22export declare enum ComparisonOperator {
23 /**
24 * Specified statistic is greater than or equal to the threshold
25 */
26 GREATER_THAN_OR_EQUAL_TO_THRESHOLD = "GreaterThanOrEqualToThreshold",
27 /**
28 * Specified statistic is strictly greater than the threshold
29 */
30 GREATER_THAN_THRESHOLD = "GreaterThanThreshold",
31 /**
32 * Specified statistic is strictly less than the threshold
33 */
34 LESS_THAN_THRESHOLD = "LessThanThreshold",
35 /**
36 * Specified statistic is less than or equal to the threshold.
37 */
38 LESS_THAN_OR_EQUAL_TO_THRESHOLD = "LessThanOrEqualToThreshold",
39 /**
40 * Specified statistic is lower than or greater than the anomaly model band.
41 * Used only for alarms based on anomaly detection models
42 */
43 LESS_THAN_LOWER_OR_GREATER_THAN_UPPER_THRESHOLD = "LessThanLowerOrGreaterThanUpperThreshold",
44 /**
45 * Specified statistic is greater than the anomaly model band.
46 * Used only for alarms based on anomaly detection models
47 */
48 GREATER_THAN_UPPER_THRESHOLD = "GreaterThanUpperThreshold",
49 /**
50 * Specified statistic is lower than the anomaly model band.
51 * Used only for alarms based on anomaly detection models
52 */
53 LESS_THAN_LOWER_THRESHOLD = "LessThanLowerThreshold"
54}
55/**
56 * Specify how missing data points are treated during alarm evaluation
57 */
58export declare enum TreatMissingData {
59 /**
60 * Missing data points are treated as breaching the threshold
61 */
62 BREACHING = "breaching",
63 /**
64 * Missing data points are treated as being within the threshold
65 */
66 NOT_BREACHING = "notBreaching",
67 /**
68 * The current alarm state is maintained
69 */
70 IGNORE = "ignore",
71 /**
72 * The alarm does not consider missing data points when evaluating whether to change state
73 */
74 MISSING = "missing"
75}
76/**
77 * An alarm on a CloudWatch metric
78 */
79export declare class Alarm extends AlarmBase {
80 /**
81 * Import an existing CloudWatch alarm provided an ARN
82 *
83 * @param scope The parent creating construct (usually `this`).
84 * @param id The construct's name
85 * @param alarmArn Alarm ARN (i.e. arn:aws:cloudwatch:<region>:<account-id>:alarm:Foo)
86 */
87 static fromAlarmArn(scope: Construct, id: string, alarmArn: string): IAlarm;
88 /**
89 * ARN of this alarm
90 *
91 * @attribute
92 */
93 readonly alarmArn: string;
94 /**
95 * Name of this alarm.
96 *
97 * @attribute
98 */
99 readonly alarmName: string;
100 /**
101 * The metric object this alarm was based on
102 */
103 readonly metric: IMetric;
104 /**
105 * This metric as an annotation
106 */
107 private readonly annotation;
108 constructor(scope: Construct, id: string, props: AlarmProps);
109 /**
110 * Turn this alarm into a horizontal annotation
111 *
112 * This is useful if you want to represent an Alarm in a non-AlarmWidget.
113 * An `AlarmWidget` can directly show an alarm, but it can only show a
114 * single alarm and no other metrics. Instead, you can convert the alarm to
115 * a HorizontalAnnotation and add it as an annotation to another graph.
116 *
117 * This might be useful if:
118 *
119 * - You want to show multiple alarms inside a single graph, for example if
120 * you have both a "small margin/long period" alarm as well as a
121 * "large margin/short period" alarm.
122 *
123 * - You want to show an Alarm line in a graph with multiple metrics in it.
124 */
125 toAnnotation(): HorizontalAnnotation;
126 /**
127 * Trigger this action if the alarm fires
128 *
129 * Typically the ARN of an SNS topic or ARN of an AutoScaling policy.
130 */
131 addAlarmAction(...actions: IAlarmAction[]): void;
132 private validateActionArn;
133 private renderMetric;
134 /**
135 * Validate that if a region is in the given stat config, they match the Alarm
136 */
137 private validateMetricStat;
138 /**
139 * Validates that the expression config does not specify searchAccount or searchRegion props
140 * as search expressions are not supported by Alarms.
141 */
142 private validateMetricExpression;
143 /**
144 * Determine if the accountId property should be included in the metric.
145 */
146 private requiresAccountId;
147}