UNPKG

9.33 kBTypeScriptView Raw
1import * as cdk from '@aws-cdk/core';
2import { IAlarm } from './alarm-base';
3import { IMetric } from './metric-types';
4import { ConcreteWidget } from './widget';
5/**
6 * Basic properties for widgets that display metrics
7 */
8export interface MetricWidgetProps {
9 /**
10 * Title for the graph
11 *
12 * @default - None
13 */
14 readonly title?: string;
15 /**
16 * The region the metrics of this graph should be taken from
17 *
18 * @default - Current region
19 */
20 readonly region?: string;
21 /**
22 * Width of the widget, in a grid of 24 units wide
23 *
24 * @default 6
25 */
26 readonly width?: number;
27 /**
28 * Height of the widget
29 *
30 * @default - 6 for Alarm and Graph widgets.
31 * 3 for single value widgets where most recent value of a metric is displayed.
32 */
33 readonly height?: number;
34}
35/**
36 * Properties for a Y-Axis
37 */
38export interface YAxisProps {
39 /**
40 * The min value
41 *
42 * @default 0
43 */
44 readonly min?: number;
45 /**
46 * The max value
47 *
48 * @default - No maximum value
49 */
50 readonly max?: number;
51 /**
52 * The label
53 *
54 * @default - No label
55 */
56 readonly label?: string;
57 /**
58 * Whether to show units
59 *
60 * @default true
61 */
62 readonly showUnits?: boolean;
63}
64/**
65 * Properties for an AlarmWidget
66 */
67export interface AlarmWidgetProps extends MetricWidgetProps {
68 /**
69 * The alarm to show
70 */
71 readonly alarm: IAlarm;
72 /**
73 * Left Y axis
74 *
75 * @default - No minimum or maximum values for the left Y-axis
76 */
77 readonly leftYAxis?: YAxisProps;
78}
79/**
80 * Display the metric associated with an alarm, including the alarm line
81 */
82export declare class AlarmWidget extends ConcreteWidget {
83 private readonly props;
84 constructor(props: AlarmWidgetProps);
85 toJson(): any[];
86}
87/**
88 * Types of view
89 */
90export declare enum GraphWidgetView {
91 /**
92 * Display as a line graph.
93 */
94 TIME_SERIES = "timeSeries",
95 /**
96 * Display as a bar graph.
97 */
98 BAR = "bar",
99 /**
100 * Display as a pie graph.
101 */
102 PIE = "pie"
103}
104/**
105 * Properties for a GraphWidget
106 */
107export interface GraphWidgetProps extends MetricWidgetProps {
108 /**
109 * Metrics to display on left Y axis
110 *
111 * @default - No metrics
112 */
113 readonly left?: IMetric[];
114 /**
115 * Metrics to display on right Y axis
116 *
117 * @default - No metrics
118 */
119 readonly right?: IMetric[];
120 /**
121 * Annotations for the left Y axis
122 *
123 * @default - No annotations
124 */
125 readonly leftAnnotations?: HorizontalAnnotation[];
126 /**
127 * Annotations for the right Y axis
128 *
129 * @default - No annotations
130 */
131 readonly rightAnnotations?: HorizontalAnnotation[];
132 /**
133 * Whether the graph should be shown as stacked lines
134 *
135 * @default false
136 */
137 readonly stacked?: boolean;
138 /**
139 * Left Y axis
140 *
141 * @default - None
142 */
143 readonly leftYAxis?: YAxisProps;
144 /**
145 * Right Y axis
146 *
147 * @default - None
148 */
149 readonly rightYAxis?: YAxisProps;
150 /**
151 * Position of the legend
152 *
153 * @default - bottom
154 */
155 readonly legendPosition?: LegendPosition;
156 /**
157 * Whether the graph should show live data
158 *
159 * @default false
160 */
161 readonly liveData?: boolean;
162 /**
163 * Display this metric
164 *
165 * @default TimeSeries
166 */
167 readonly view?: GraphWidgetView;
168 /**
169 * Whether to show the value from the entire time range. Only applicable for Bar and Pie charts.
170 *
171 * If false, values will be from the most recent period of your chosen time range;
172 * if true, shows the value from the entire time range.
173 *
174 * @default false
175 */
176 readonly setPeriodToTimeRange?: boolean;
177 /**
178 * The default period for all metrics in this widget.
179 * The period is the length of time represented by one data point on the graph.
180 * This default can be overridden within each metric definition.
181 *
182 * @default cdk.Duration.seconds(300)
183 */
184 readonly period?: cdk.Duration;
185 /**
186 * The default statistic to be displayed for each metric.
187 * This default can be overridden within the definition of each individual metric
188 *
189 * @default - The statistic for each metric is used
190 */
191 readonly statistic?: string;
192}
193/**
194 * A dashboard widget that displays metrics
195 */
196export declare class GraphWidget extends ConcreteWidget {
197 private readonly props;
198 private readonly leftMetrics;
199 private readonly rightMetrics;
200 constructor(props: GraphWidgetProps);
201 /**
202 * Add another metric to the left Y axis of the GraphWidget
203 *
204 * @param metric the metric to add
205 */
206 addLeftMetric(metric: IMetric): void;
207 /**
208 * Add another metric to the right Y axis of the GraphWidget
209 *
210 * @param metric the metric to add
211 */
212 addRightMetric(metric: IMetric): void;
213 toJson(): any[];
214}
215/**
216 * Properties for a SingleValueWidget
217 */
218export interface SingleValueWidgetProps extends MetricWidgetProps {
219 /**
220 * Metrics to display
221 */
222 readonly metrics: IMetric[];
223 /**
224 * Whether to show the value from the entire time range.
225 *
226 * @default false
227 */
228 readonly setPeriodToTimeRange?: boolean;
229 /**
230 * Whether to show as many digits as can fit, before rounding.
231 *
232 * @default false
233 */
234 readonly fullPrecision?: boolean;
235}
236/**
237 * A dashboard widget that displays the most recent value for every metric
238 */
239export declare class SingleValueWidget extends ConcreteWidget {
240 private readonly props;
241 constructor(props: SingleValueWidgetProps);
242 toJson(): any[];
243}
244/**
245 * The properties for a CustomWidget
246 */
247export interface CustomWidgetProps {
248 /**
249 * The Arn of the AWS Lambda function that returns HTML or JSON that will be displayed in the widget
250 */
251 readonly functionArn: string;
252 /**
253 * Width of the widget, in a grid of 24 units wide
254 *
255 * @default 6
256 */
257 readonly width?: number;
258 /**
259 * Height of the widget
260 *
261 * @default - 6 for Alarm and Graph widgets.
262 * 3 for single value widgets where most recent value of a metric is displayed.
263 */
264 readonly height?: number;
265 /**
266 * The title of the widget
267 */
268 readonly title: string;
269 /**
270 * Update the widget on refresh
271 *
272 * @default true
273 */
274 readonly updateOnRefresh?: boolean;
275 /**
276 * Update the widget on resize
277 *
278 * @default true
279 */
280 readonly updateOnResize?: boolean;
281 /**
282 * Update the widget on time range change
283 *
284 * @default true
285 */
286 readonly updateOnTimeRangeChange?: boolean;
287 /**
288 * Parameters passed to the lambda function
289 *
290 * @default - no parameters are passed to the lambda function
291 */
292 readonly params?: any;
293}
294/**
295 * A CustomWidget shows the result of a AWS lambda function
296 */
297export declare class CustomWidget extends ConcreteWidget {
298 private readonly props;
299 constructor(props: CustomWidgetProps);
300 toJson(): any[];
301}
302/**
303 * Horizontal annotation to be added to a graph
304 */
305export interface HorizontalAnnotation {
306 /**
307 * The value of the annotation
308 */
309 readonly value: number;
310 /**
311 * Label for the annotation
312 *
313 * @default - No label
314 */
315 readonly label?: string;
316 /**
317 * The hex color code, prefixed with '#' (e.g. '#00ff00'), to be used for the annotation.
318 * The `Color` class has a set of standard colors that can be used here.
319 *
320 * @default - Automatic color
321 */
322 readonly color?: string;
323 /**
324 * Add shading above or below the annotation
325 *
326 * @default No shading
327 */
328 readonly fill?: Shading;
329 /**
330 * Whether the annotation is visible
331 *
332 * @default true
333 */
334 readonly visible?: boolean;
335}
336/**
337 * Fill shading options that will be used with an annotation
338 */
339export declare enum Shading {
340 /**
341 * Don't add shading
342 */
343 NONE = "none",
344 /**
345 * Add shading above the annotation
346 */
347 ABOVE = "above",
348 /**
349 * Add shading below the annotation
350 */
351 BELOW = "below"
352}
353/**
354 * A set of standard colours that can be used in annotations in a GraphWidget.
355 */
356export declare class Color {
357 /** blue - hex #1f77b4 */
358 static readonly BLUE = "#1f77b4";
359 /** brown - hex #8c564b */
360 static readonly BROWN = "#8c564b";
361 /** green - hex #2ca02c */
362 static readonly GREEN = "#2ca02c";
363 /** grey - hex #7f7f7f */
364 static readonly GREY = "#7f7f7f";
365 /** orange - hex #ff7f0e */
366 static readonly ORANGE = "#ff7f0e";
367 /** pink - hex #e377c2 */
368 static readonly PINK = "#e377c2";
369 /** purple - hex #9467bd */
370 static readonly PURPLE = "#9467bd";
371 /** red - hex #d62728 */
372 static readonly RED = "#d62728";
373 private constructor();
374}
375/**
376 * The position of the legend on a GraphWidget.
377 */
378export declare enum LegendPosition {
379 /**
380 * Legend appears below the graph (default).
381 */
382 BOTTOM = "bottom",
383 /**
384 * Add shading above the annotation
385 */
386 RIGHT = "right",
387 /**
388 * Add shading below the annotation
389 */
390 HIDDEN = "hidden"
391}