UNPKG

9.6 kBTypeScriptView Raw
1import { Duration } from '@aws-cdk/core';
2/**
3 * Interface for metrics
4 */
5export interface IMetric {
6 /**
7 * Any warnings related to this metric
8 *
9 * Should be attached to the consuming construct.
10 *
11 * @default - None
12 */
13 readonly warnings?: string[];
14 /**
15 * Inspect the details of the metric object
16 */
17 toMetricConfig(): MetricConfig;
18 /**
19 * Turn this metric object into an alarm configuration
20 *
21 * @deprecated Use `toMetricConfig()` instead.
22 */
23 toAlarmConfig(): MetricAlarmConfig;
24 /**
25 * Turn this metric object into a graph configuration
26 *
27 * @deprecated Use `toMetricConfig()` instead.
28 */
29 toGraphConfig(): MetricGraphConfig;
30}
31/**
32 * Metric dimension
33 *
34 * @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cw-dimension.html
35 *
36 */
37export interface Dimension {
38 /**
39 * Name of the dimension
40 */
41 readonly name: string;
42 /**
43 * Value of the dimension
44 */
45 readonly value: any;
46}
47/**
48 * Statistic to use over the aggregation period
49 */
50export declare enum Statistic {
51 /**
52 * The count (number) of data points used for the statistical calculation.
53 */
54 SAMPLE_COUNT = "SampleCount",
55 /**
56 * The value of Sum / SampleCount during the specified period.
57 */
58 AVERAGE = "Average",
59 /**
60 * All values submitted for the matching metric added together.
61 * This statistic can be useful for determining the total volume of a metric.
62 */
63 SUM = "Sum",
64 /**
65 * The lowest value observed during the specified period.
66 * You can use this value to determine low volumes of activity for your application.
67 */
68 MINIMUM = "Minimum",
69 /**
70 * The highest value observed during the specified period.
71 * You can use this value to determine high volumes of activity for your application.
72 */
73 MAXIMUM = "Maximum"
74}
75/**
76 * Unit for metric
77 */
78export declare enum Unit {
79 /**
80 * Seconds
81 */
82 SECONDS = "Seconds",
83 /**
84 * Microseconds
85 */
86 MICROSECONDS = "Microseconds",
87 /**
88 * Milliseconds
89 */
90 MILLISECONDS = "Milliseconds",
91 /**
92 * Bytes
93 */
94 BYTES = "Bytes",
95 /**
96 * Kilobytes
97 */
98 KILOBYTES = "Kilobytes",
99 /**
100 * Megabytes
101 */
102 MEGABYTES = "Megabytes",
103 /**
104 * Gigabytes
105 */
106 GIGABYTES = "Gigabytes",
107 /**
108 * Terabytes
109 */
110 TERABYTES = "Terabytes",
111 /**
112 * Bits
113 */
114 BITS = "Bits",
115 /**
116 * Kilobits
117 */
118 KILOBITS = "Kilobits",
119 /**
120 * Megabits
121 */
122 MEGABITS = "Megabits",
123 /**
124 * Gigabits
125 */
126 GIGABITS = "Gigabits",
127 /**
128 * Terabits
129 */
130 TERABITS = "Terabits",
131 /**
132 * Percent
133 */
134 PERCENT = "Percent",
135 /**
136 * Count
137 */
138 COUNT = "Count",
139 /**
140 * Bytes/second (B/s)
141 */
142 BYTES_PER_SECOND = "Bytes/Second",
143 /**
144 * Kilobytes/second (kB/s)
145 */
146 KILOBYTES_PER_SECOND = "Kilobytes/Second",
147 /**
148 * Megabytes/second (MB/s)
149 */
150 MEGABYTES_PER_SECOND = "Megabytes/Second",
151 /**
152 * Gigabytes/second (GB/s)
153 */
154 GIGABYTES_PER_SECOND = "Gigabytes/Second",
155 /**
156 * Terabytes/second (TB/s)
157 */
158 TERABYTES_PER_SECOND = "Terabytes/Second",
159 /**
160 * Bits/second (b/s)
161 */
162 BITS_PER_SECOND = "Bits/Second",
163 /**
164 * Kilobits/second (kb/s)
165 */
166 KILOBITS_PER_SECOND = "Kilobits/Second",
167 /**
168 * Megabits/second (Mb/s)
169 */
170 MEGABITS_PER_SECOND = "Megabits/Second",
171 /**
172 * Gigabits/second (Gb/s)
173 */
174 GIGABITS_PER_SECOND = "Gigabits/Second",
175 /**
176 * Terabits/second (Tb/s)
177 */
178 TERABITS_PER_SECOND = "Terabits/Second",
179 /**
180 * Count/second
181 */
182 COUNT_PER_SECOND = "Count/Second",
183 /**
184 * None
185 */
186 NONE = "None"
187}
188/**
189 * Properties of a rendered metric
190 */
191export interface MetricConfig {
192 /**
193 * In case the metric represents a query, the details of the query
194 *
195 * @default - None
196 */
197 readonly metricStat?: MetricStatConfig;
198 /**
199 * In case the metric is a math expression, the details of the math expression
200 *
201 * @default - None
202 */
203 readonly mathExpression?: MetricExpressionConfig;
204 /**
205 * Additional properties which will be rendered if the metric is used in a dashboard
206 *
207 * Examples are 'label' and 'color', but any key in here will be
208 * added to dashboard graphs.
209 *
210 * @default - None
211 */
212 readonly renderingProperties?: Record<string, unknown>;
213}
214/**
215 * Properties for a concrete metric
216 *
217 * NOTE: `unit` is no longer on this object since it is only used for `Alarms`, and doesn't mean what one
218 * would expect it to mean there anyway. It is most likely to be misused.
219 */
220export interface MetricStatConfig {
221 /**
222 * The dimensions to apply to the alarm
223 *
224 * @default []
225 */
226 readonly dimensions?: Dimension[];
227 /**
228 * Namespace of the metric
229 */
230 readonly namespace: string;
231 /**
232 * Name of the metric
233 */
234 readonly metricName: string;
235 /**
236 * How many seconds to aggregate over
237 */
238 readonly period: Duration;
239 /**
240 * Aggregation function to use (can be either simple or a percentile)
241 */
242 readonly statistic: string;
243 /**
244 * Unit used to filter the metric stream
245 *
246 * Only refer to datums emitted to the metric stream with the given unit and
247 * ignore all others. Only useful when datums are being emitted to the same
248 * metric stream under different units.
249 *
250 * This field has been renamed from plain `unit` to clearly communicate
251 * its purpose.
252 *
253 * @default - Refer to all metric datums
254 */
255 readonly unitFilter?: Unit;
256 /**
257 * Region which this metric comes from.
258 *
259 * @default Deployment region.
260 */
261 readonly region?: string;
262 /**
263 * Account which this metric comes from.
264 *
265 * @default Deployment account.
266 */
267 readonly account?: string;
268}
269/**
270 * Properties for a concrete metric
271 */
272export interface MetricExpressionConfig {
273 /**
274 * Math expression for the metric.
275 */
276 readonly expression: string;
277 /**
278 * Metrics used in the math expression
279 */
280 readonly usingMetrics: Record<string, IMetric>;
281 /**
282 * How many seconds to aggregate over
283 */
284 readonly period: number;
285 /**
286 * Account to evaluate search expressions within.
287 *
288 * @default - Deployment account.
289 */
290 readonly searchAccount?: string;
291 /**
292 * Region to evaluate search expressions within.
293 *
294 * @default - Deployment region.
295 */
296 readonly searchRegion?: string;
297}
298/**
299 * Properties used to construct the Metric identifying part of an Alarm
300 *
301 * @deprecated Replaced by MetricConfig
302 */
303export interface MetricAlarmConfig {
304 /**
305 * The dimensions to apply to the alarm
306 */
307 readonly dimensions?: Dimension[];
308 /**
309 * Namespace of the metric
310 */
311 readonly namespace: string;
312 /**
313 * Name of the metric
314 */
315 readonly metricName: string;
316 /**
317 * How many seconds to aggregate over
318 */
319 readonly period: number;
320 /**
321 * Simple aggregation function to use
322 */
323 readonly statistic?: Statistic;
324 /**
325 * Percentile aggregation function to use
326 */
327 readonly extendedStatistic?: string;
328 /**
329 * The unit of the alarm
330 */
331 readonly unit?: Unit;
332}
333/**
334 * Properties used to construct the Metric identifying part of a Graph
335 *
336 * @deprecated Replaced by MetricConfig
337 */
338export interface MetricGraphConfig {
339 /**
340 * The dimensions to apply to the alarm
341 */
342 readonly dimensions?: Dimension[];
343 /**
344 * Namespace of the metric
345 */
346 readonly namespace: string;
347 /**
348 * Name of the metric
349 */
350 readonly metricName: string;
351 /**
352 * Rendering properties override yAxis parameter of the widget object
353 */
354 readonly renderingProperties: MetricRenderingProperties;
355 /**
356 * How many seconds to aggregate over
357 *
358 * @deprecated Use `period` in `renderingProperties`
359 */
360 readonly period: number;
361 /**
362 * Label for the metric
363 *
364 * @deprecated Use `label` in `renderingProperties`
365 */
366 readonly label?: string;
367 /**
368 * Color for the graph line
369 *
370 * @deprecated Use `color` in `renderingProperties`
371 */
372 readonly color?: string;
373 /**
374 * Aggregation function to use (can be either simple or a percentile)
375 *
376 * @deprecated Use `stat` in `renderingProperties`
377 */
378 readonly statistic?: string;
379 /**
380 * The unit of the alarm
381 *
382 * @deprecated not used in dashboard widgets
383 */
384 readonly unit?: Unit;
385}
386/**
387 * Custom rendering properties that override the default rendering properties specified in the yAxis parameter of the widget object.
388 *
389 * @deprecated Replaced by MetricConfig.
390 */
391export interface MetricRenderingProperties {
392 /**
393 * How many seconds to aggregate over
394 */
395 readonly period: number;
396 /**
397 * Label for the metric
398 */
399 readonly label?: string;
400 /**
401 * The hex color code, prefixed with '#' (e.g. '#00ff00'), to use when this metric is rendered on a graph.
402 * The `Color` class has a set of standard colors that can be used here.
403 */
404 readonly color?: string;
405 /**
406 * Aggregation function to use (can be either simple or a percentile)
407 */
408 readonly stat?: string;
409}