Skip to content

Commit

Permalink
Merge branch 'master' into njlynch/rds-cluster-cwlogs
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] committed Aug 18, 2020
2 parents 785fd2f + cace51a commit d49a2eb
Show file tree
Hide file tree
Showing 63 changed files with 6,074 additions and 385 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/issue-label-assign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
{"keywords":["[@aws-cdk/aws-certificatemanager]","[aws-certificatemanager]","[certificatemanager]","[certificate manager]","[certificate-manager]","[acm]"],"labels":["@aws-cdk/aws-certificatemanager"],"assignees":["njlynch"]},
{"keywords":["[@aws-cdk/aws-chatbot]","[aws-chatbot]","[chatbot]"],"labels":["@aws-cdk/aws-chatbot"],"assignees":["MrArnoldPalmer"]},
{"keywords":["[@aws-cdk/aws-cloud9]","[aws-cloud9]","[cloud9]","[cloud 9]"],"labels":["@aws-cdk/aws-cloud9"],"assignees":["skinny85"]},
{"keywords":["[@aws-cdk/aws-cloudformation]","[aws-cloudformation]","[cloudformation]","[cloud formation]"],"labels":["@aws-cdk/aws-cloudformation"],"assignees":["eladb"]},
{"keywords":["[@aws-cdk/aws-cloudformation]","[aws-cloudformation]","[cloudformation]","[cloud formation]"],"labels":["@aws-cdk/aws-cloudformation"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/aws-cloudfront]","[aws-cloudfront]","[cloudfront]","[cloud front]"],"labels":["@aws-cdk/aws-cloudfront"],"assignees":["iliapolo"]},
{"keywords":["[@aws-cdk/aws-cloudfront-origins]","[aws-cloudfront-origins]","[cloudfront-origins]","[cloudfront origins]"],"labels":["@aws-cdk/aws-cloudfront-origins"],"assignees":["iliapolo"]},
{"keywords":["[@aws-cdk/aws-cloudtrail]","[aws-cloudtrail]","[cloudtrail]","[cloud trail]"],"labels":["@aws-cdk/aws-cloudtrail"],"assignees":["rix0rrr"]},
Expand Down Expand Up @@ -157,13 +157,13 @@ jobs:
{"keywords":["[@aws-cdk/aws-wafregional]","[aws-wafregional]","[wafregional]","[waf regional]","[waf-regional]"],"labels":["@aws-cdk/aws-wafregional"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/aws-wafv2]","[aws-wafv2]","[wafv2]","[waf v2]","[waf-v2]"],"labels":["@aws-cdk/aws-wafv2"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/aws-workspaces]","[aws-workspaces]","[workspaces]"],"labels":["@aws-cdk/aws-workspaces"],"assignees":["NetaNir"]},
{"keywords":["[@aws-cdk/cfnspec]","[cfnspec]","[cfn spec]","[cfn-spec]"],"labels":["@aws-cdk/cfnspec"],"assignees":["eladb"]},
{"keywords":["[@aws-cdk/cloud-assembly-schema]","[cloud-assembly-schema]","[cloud assembly schema]"],"labels":["@aws-cdk/cloud-assembly-schema"],"assignees":["eladb"]},
{"keywords":["[@aws-cdk/cfnspec]","[cfnspec]","[cfn spec]","[cfn-spec]"],"labels":["@aws-cdk/cfnspec"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/cloud-assembly-schema]","[cloud-assembly-schema]","[cloud assembly schema]"],"labels":["@aws-cdk/cloud-assembly-schema"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/cloudformation-diff]","[cloudformation-diff]","[cloudformation diff]","[cfn diff]"],"labels":["@aws-cdk/cloudformation-diff"],"assignees":["shivlaks"]},
{"keywords":["[@aws-cdk/cloudformation-include]","[cloudformation-include]","[cloudformation include]","[cfn include]","[cfn-include]"],"labels":["@aws-cdk/cloudformation-include"],"assignees":["skinny85"]},
{"keywords":["[@aws-cdk/core]","[core]"],"labels":["@aws-cdk/core"],"assignees":["eladb"]},
{"keywords":["[@aws-cdk/custom-resources]","[custom-resources]","[custom resources]"],"labels":["@aws-cdk/custom-resources"],"assignees":["eladb"]},
{"keywords":["[@aws-cdk/cx-api]","[cx-api]","[cx api]"],"labels":["@aws-cdk/cx-api"],"assignees":["eladb"]},
{"keywords":["[@aws-cdk/core]","[core]"],"labels":["@aws-cdk/core"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/custom-resources]","[custom-resources]","[custom resources]"],"labels":["@aws-cdk/custom-resources"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/cx-api]","[cx-api]","[cx api]"],"labels":["@aws-cdk/cx-api"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/region-info]","[region-info]","[region info]"],"labels":["@aws-cdk/region-info"],"assignees":["RomainMuller"]},
{"keywords":["[@aws-cdk/aws-macie]","[aws-macie]","[macie]"],"labels":["@aws-cdk/aws-macie"],"assignees":["rix0rrr"]},
{"keywords":["[@aws-cdk/pipelines]","[pipelines]","[cdk pipelines]","[cdk-pipelines]"],"labels":["@aws-cdk/pipelines"],"assignees":["rix0rrr"]}
Expand Down
7 changes: 5 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/stage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Construct, Duration, IResource, Resource, Stack } from '@aws-cdk/core';
import { Construct, Duration, IResource, Resource, Stack, Token } from '@aws-cdk/core';
import { AccessLogFormat, IAccessLogDestination } from './access-log';
import { CfnStage } from './apigateway.generated';
import { Deployment } from './deployment';
Expand Down Expand Up @@ -210,7 +210,10 @@ export class Stage extends Resource implements IStage {
if (!accessLogDestination && !accessLogFormat) {
accessLogSetting = undefined;
} else {
if (accessLogFormat !== undefined && !/.*\$context.requestId.*/.test(accessLogFormat.toString())) {
if (accessLogFormat !== undefined &&
!Token.isUnresolved(accessLogFormat.toString()) &&
!/.*\$context.requestId.*/.test(accessLogFormat.toString())) {

throw new Error('Access log must include at least `AccessLogFormat.contextRequestId()`');
}
if (accessLogFormat !== undefined && accessLogDestination === undefined) {
Expand Down
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-apigateway/test/test.stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,27 @@ export = {
test.done();
},

'does not fail when access log format is a token'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const api = new apigateway.RestApi(stack, 'test-api', { cloudWatchRole: false, deploy: false });
const deployment = new apigateway.Deployment(stack, 'my-deployment', { api });
api.root.addMethod('GET');

// WHEN
const testLogGroup = new logs.LogGroup(stack, 'LogGroup');
const testFormat = apigateway.AccessLogFormat.custom(cdk.Lazy.stringValue({ produce: () => 'test' }));

// THEN
test.doesNotThrow(() => new apigateway.Stage(stack, 'my-stage', {
deployment,
accessLogDestination: new apigateway.LogGroupLogDestination(testLogGroup),
accessLogFormat: testFormat,
}));

test.done();
},

'fails when access log destination is empty'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export enum PredefinedMetric {
*/
ECS_SERVICE_AVERAGE_CPU_UTILIZATION = 'ECSServiceAverageCPUUtilization',
/**
* ECS_SERVICE_AVERAGE_CPU_UTILIZATION
* ECS_SERVICE_AVERAGE_MEMORY_UTILIZATION
* @see https://docs.aws.amazon.com/autoscaling/application/APIReference/API_PredefinedMetricSpecification.html
*/
ECS_SERVICE_AVERAGE_MEMORY_UTILIZATION = 'ECSServiceAverageMemoryUtilization',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-appmesh/lib/shared-interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface PortMapping {
readonly port: number;

/**
* Protocol for the VirtualNode / Route, only TCP or HTTP supported
* Protocol for the VirtualNode / Route, only GRPC, HTTP, HTTP2, or TCP is supported
*
* @default HTTP
*/
Expand Down
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-cloudwatch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ A `LogQueryWidget` shows the results of a query from Logs Insights:
```ts
dashboard.addWidgets(new LogQueryWidget({
logGroupNames: ['my-log-group'],
view: LogQueryVisualizationType.TABLE,
// The lines will be automatically combined using '\n|'.
queryLines: [
'fields @message',
Expand Down
54 changes: 48 additions & 6 deletions packages/@aws-cdk/aws-cloudwatch/lib/log-query.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import * as cdk from '@aws-cdk/core';
import { ConcreteWidget } from './widget';

/**
* Types of view
*/
export enum LogQueryVisualizationType {
/**
* Table view
*/
TABLE = 'table',
/**
* Line view
*/
LINE = 'line',
/**
* Stacked area view
*/
STACKEDAREA = 'stackedarea',
/**
* Bar view
*/
BAR = 'bar',
/**
* Pie view
*/
PIE = 'pie',
}

/**
* Properties for a Query widget
*/
Expand Down Expand Up @@ -43,6 +69,13 @@ export interface LogQueryWidgetProps {
*/
readonly region?: string;

/**
* The type of view to use
*
* @default LogQueryVisualizationType.TABLE
*/
readonly view?: LogQueryVisualizationType;

/**
* Width of the widget, in a grid of 24 units wide
*
Expand Down Expand Up @@ -83,18 +116,27 @@ export class LogQueryWidget extends ConcreteWidget {
? this.props.queryLines.join('\n| ')
: this.props.queryString;

const properties: any = {
view: this.props.view? this.props.view : LogQueryVisualizationType.TABLE,
title: this.props.title,
region: this.props.region || cdk.Aws.REGION,
query: `${sources} | ${query}`,
};

// adding stacked property in case of LINE or STACKEDAREA
if (this.props.view === LogQueryVisualizationType.LINE || this.props.view === LogQueryVisualizationType.STACKEDAREA) {
// assign the right native view value. both types share the same value
properties.view = 'timeSeries',
properties.stacked = this.props.view === LogQueryVisualizationType.STACKEDAREA ? true : false;
}

return [{
type: 'log',
width: this.width,
height: this.height,
x: this.x,
y: this.y,
properties: {
view: 'table',
title: this.props.title,
region: this.props.region || cdk.Aws.REGION,
query: `${sources} | ${query}`,
},
properties: properties,
}];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@
{
"Ref": "AWS::Region"
},
"\",\"query\":\"SOURCE 'my-log-group' | fields @message\\n | filter @message like /Error/\"}},{\"type\":\"log\",\"width\":6,\"height\":6,\"x\":0,\"y\":23,\"properties\":{\"view\":\"bar\",\"title\":\"Errors in my log group - bar\",\"region\":\"",
{
"Ref": "AWS::Region"
},
"\",\"query\":\"SOURCE 'my-log-group' | fields @message\\n | filter @message like /Error/\"}},{\"type\":\"log\",\"width\":6,\"height\":6,\"x\":0,\"y\":29,\"properties\":{\"view\":\"timeSeries\",\"title\":\"Errors in my log group - line\",\"region\":\"",
{
"Ref": "AWS::Region"
},
"\",\"query\":\"SOURCE 'my-log-group' | fields @message\\n | filter @message like /Error/\",\"stacked\":false}},{\"type\":\"log\",\"width\":6,\"height\":6,\"x\":0,\"y\":35,\"properties\":{\"view\":\"timeSeries\",\"title\":\"Errors in my log group - stacked\",\"region\":\"",
{
"Ref": "AWS::Region"
},
"\",\"query\":\"SOURCE 'my-log-group' | fields @message\\n | filter @message like /Error/\",\"stacked\":true}},{\"type\":\"log\",\"width\":6,\"height\":6,\"x\":0,\"y\":41,\"properties\":{\"view\":\"pie\",\"title\":\"Errors in my log group - pie\",\"region\":\"",
{
"Ref": "AWS::Region"
},
"\",\"query\":\"SOURCE 'my-log-group' | fields @message\\n | filter @message like /Error/\"}}]}"
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as cloudwatch from '../lib';

const app = new cdk.App();

const stack = new cdk.Stack(app, 'aws-cdk-cloudwatch');
const stack = new cdk.Stack(app, 'aws-cdk-cloudwatch-alarms');

const queue = new cdk.CfnResource(stack, 'queue', { type: 'AWS::SQS::Queue' });

Expand Down Expand Up @@ -54,5 +54,33 @@ dashboard.addWidgets(new cloudwatch.LogQueryWidget({
queryString: `fields @message
| filter @message like /Error/`,
}));
dashboard.addWidgets(new cloudwatch.LogQueryWidget({
title: 'Errors in my log group - bar',
view: cloudwatch.LogQueryVisualizationType.BAR,
logGroupNames: ['my-log-group'],
queryString: `fields @message
| filter @message like /Error/`,
}));
dashboard.addWidgets(new cloudwatch.LogQueryWidget({
title: 'Errors in my log group - line',
view: cloudwatch.LogQueryVisualizationType.LINE,
logGroupNames: ['my-log-group'],
queryString: `fields @message
| filter @message like /Error/`,
}));
dashboard.addWidgets(new cloudwatch.LogQueryWidget({
title: 'Errors in my log group - stacked',
view: cloudwatch.LogQueryVisualizationType.STACKEDAREA,
logGroupNames: ['my-log-group'],
queryString: `fields @message
| filter @message like /Error/`,
}));
dashboard.addWidgets(new cloudwatch.LogQueryWidget({
title: 'Errors in my log group - pie',
view: cloudwatch.LogQueryVisualizationType.PIE,
logGroupNames: ['my-log-group'],
queryString: `fields @message
| filter @message like /Error/`,
}));

app.synth();
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,31 @@
[
"(((ALARM(",
{
"Fn::GetAtt": [ "Alarm1F9009D71", "Arn" ]
"Fn::GetAtt": [
"Alarm1F9009D71",
"Arn"
]
},
") OR OK(",
{
"Fn::GetAtt": [ "Alarm2A7122E13", "Arn" ]
"Fn::GetAtt": [
"Alarm2A7122E13",
"Arn"
]
},
") OR ALARM(",
{
"Fn::GetAtt": [ "Alarm32341D8D9", "Arn" ]
"Fn::GetAtt": [
"Alarm32341D8D9",
"Arn"
]
},
")) AND (NOT (INSUFFICIENT_DATA(",
{
"Fn::GetAtt":[ "Alarm4671832C8", "Arn" ]
"Fn::GetAtt": [
"Alarm4671832C8",
"Arn"
]
},
")))) OR FALSE)"
]
Expand Down

0 comments on commit d49a2eb

Please sign in to comment.