1 | ;
|
2 | var _a;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.LogQueryWidget = exports.LogQueryVisualizationType = void 0;
|
5 | const jsiiDeprecationWarnings = require("../.warnings.jsii.js");
|
6 | const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
7 | const cdk = require("@aws-cdk/core");
|
8 | const widget_1 = require("./widget");
|
9 | /**
|
10 | * Types of view
|
11 | */
|
12 | var LogQueryVisualizationType;
|
13 | (function (LogQueryVisualizationType) {
|
14 | /**
|
15 | * Table view
|
16 | */
|
17 | LogQueryVisualizationType["TABLE"] = "table";
|
18 | /**
|
19 | * Line view
|
20 | */
|
21 | LogQueryVisualizationType["LINE"] = "line";
|
22 | /**
|
23 | * Stacked area view
|
24 | */
|
25 | LogQueryVisualizationType["STACKEDAREA"] = "stackedarea";
|
26 | /**
|
27 | * Bar view
|
28 | */
|
29 | LogQueryVisualizationType["BAR"] = "bar";
|
30 | /**
|
31 | * Pie view
|
32 | */
|
33 | LogQueryVisualizationType["PIE"] = "pie";
|
34 | })(LogQueryVisualizationType = exports.LogQueryVisualizationType || (exports.LogQueryVisualizationType = {}));
|
35 | /**
|
36 | * Display query results from Logs Insights
|
37 | */
|
38 | class LogQueryWidget extends widget_1.ConcreteWidget {
|
39 | constructor(props) {
|
40 | super(props.width || 6, props.height || 6);
|
41 | try {
|
42 | jsiiDeprecationWarnings._aws_cdk_aws_cloudwatch_LogQueryWidgetProps(props);
|
43 | }
|
44 | catch (error) {
|
45 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
46 | Error.captureStackTrace(error, LogQueryWidget);
|
47 | }
|
48 | throw error;
|
49 | }
|
50 | this.props = props;
|
51 | if (props.logGroupNames.length === 0) {
|
52 | throw new Error('Specify at least one log group name.');
|
53 | }
|
54 | if (!!props.queryString === !!props.queryLines) {
|
55 | throw new Error('Specify exactly one of \'queryString\' and \'queryLines\'');
|
56 | }
|
57 | }
|
58 | toJson() {
|
59 | const sources = this.props.logGroupNames.map(l => `SOURCE '${l}'`).join(' | ');
|
60 | const query = this.props.queryLines
|
61 | ? this.props.queryLines.join('\n| ')
|
62 | : this.props.queryString;
|
63 | const properties = {
|
64 | view: this.props.view ? this.props.view : LogQueryVisualizationType.TABLE,
|
65 | title: this.props.title,
|
66 | region: this.props.region || cdk.Aws.REGION,
|
67 | query: `${sources} | ${query}`,
|
68 | };
|
69 | // adding stacked property in case of LINE or STACKEDAREA
|
70 | if (this.props.view === LogQueryVisualizationType.LINE || this.props.view === LogQueryVisualizationType.STACKEDAREA) {
|
71 | // assign the right native view value. both types share the same value
|
72 | properties.view = 'timeSeries',
|
73 | properties.stacked = this.props.view === LogQueryVisualizationType.STACKEDAREA ? true : false;
|
74 | }
|
75 | return [{
|
76 | type: 'log',
|
77 | width: this.width,
|
78 | height: this.height,
|
79 | x: this.x,
|
80 | y: this.y,
|
81 | properties: properties,
|
82 | }];
|
83 | }
|
84 | }
|
85 | exports.LogQueryWidget = LogQueryWidget;
|
86 | _a = JSII_RTTI_SYMBOL_1;
|
87 | LogQueryWidget[_a] = { fqn: "@aws-cdk/aws-cloudwatch.LogQueryWidget", version: "1.198.0" };
|
88 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9nLXF1ZXJ5LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibG9nLXF1ZXJ5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLHFDQUFxQztBQUNyQyxxQ0FBMEM7QUFFMUM7O0dBRUc7QUFDSCxJQUFZLHlCQXFCWDtBQXJCRCxXQUFZLHlCQUF5QjtJQUNuQzs7T0FFRztJQUNILDRDQUFlLENBQUE7SUFDZjs7T0FFRztJQUNILDBDQUFhLENBQUE7SUFDYjs7T0FFRztJQUNILHdEQUEyQixDQUFBO0lBQzNCOztPQUVHO0lBQ0gsd0NBQVcsQ0FBQTtJQUNYOztPQUVHO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