Skip to content

Commit

Permalink
chore(logs): line break for CloudWatch Logs Insights Query Definition (
Browse files Browse the repository at this point in the history
…#23094)

fix(logs): Adding line break for CloudWatch Logs Insights Query Definition (#22422)

Verified in AWS Console with integration test, we can see query in multiple lines instead of a single line.

<img width="1159" alt="image" src="https://user-images.githubusercontent.com/7830699/204059301-afd0adb7-b24e-4588-a0aa-58fd0cdbbfd8.png">

----

### All Submissions:

* [✅] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [❌] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [✅] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [✅] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jerry-shao authored Nov 26, 2022
1 parent 6754746 commit 86c6f9d
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 57 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-logs/lib/query-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class QueryString {
sort: this.sort,
limit: this.limit,
display: this.display,
}).join(' | ');
}).join('\n| ');
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": "21.0.0",
"files": {
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
"source": {
"path": "LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
}
},
"dockerImages": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"Parameters": {
"BootstrapVersion": {
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
}
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
{
"Assert": {
"Fn::Not": [
{
"Fn::Contains": [
[
"1",
"2",
"3",
"4",
"5"
],
{
"Ref": "BootstrapVersion"
}
]
}
]
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"version": "20.0.0",
"version": "21.0.0",
"files": {
"d7519d4b81ac956c2d9f2743e08d54bd88921e1a0ad4223a8268703d3d4fbede": {
"e6a0a51961925fbc37d9b81431449c256ed453f98089eb70f83850f237b4d722": {
"source": {
"path": "aws-cdk-logs-querydefinition-integ.template.json",
"path": "aws-cdk-logs-insights-querydefinition-integ.template.json",
"packaging": "file"
},
"destinations": {
"current_account-current_region": {
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
"objectKey": "d7519d4b81ac956c2d9f2743e08d54bd88921e1a0ad4223a8268703d3d4fbede.json",
"objectKey": "e6a0a51961925fbc37d9b81431449c256ed453f98089eb70f83850f237b4d722.json",
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"Type": "AWS::Logs::QueryDefinition",
"Properties": {
"Name": "QueryDefinition",
"QueryString": "fields @timestamp, @message | parse @message \"[*] *\" as loggingType, loggingMessage | filter loggingType = \"ERROR\" | sort @timestamp desc | limit 20 | display loggingMessage",
"QueryString": "fields @timestamp, @message\n| parse @message \"[*] *\" as loggingType, loggingMessage\n| filter loggingType = \"ERROR\"\n| sort @timestamp desc\n| limit 20\n| display loggingMessage",
"LogGroupNames": [
{
"Ref": "LogGroupF5B46931"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"20.0.0"}
{"version":"21.0.0"}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"version": "20.0.0",
"version": "21.0.0",
"testCases": {
"integ.save-logs-insights-query-definition": {
"LogsInsightsQueryDefinitionIntegTest/DefaultTest": {
"stacks": [
"aws-cdk-logs-querydefinition-integ"
"aws-cdk-logs-insights-querydefinition-integ"
],
"diffAssets": false,
"stackUpdateWorkflow": true
"assertionStack": "LogsInsightsQueryDefinitionIntegTest/DefaultTest/DeployAssert",
"assertionStackName": "LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5"
}
},
"synthContext": {},
"enableLookups": false
}
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
{
"version": "20.0.0",
"version": "21.0.0",
"artifacts": {
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
},
"aws-cdk-logs-querydefinition-integ.assets": {
"aws-cdk-logs-insights-querydefinition-integ.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "aws-cdk-logs-querydefinition-integ.assets.json",
"file": "aws-cdk-logs-insights-querydefinition-integ.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"aws-cdk-logs-querydefinition-integ": {
"aws-cdk-logs-insights-querydefinition-integ": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "aws-cdk-logs-querydefinition-integ.template.json",
"templateFile": "aws-cdk-logs-insights-querydefinition-integ.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/d7519d4b81ac956c2d9f2743e08d54bd88921e1a0ad4223a8268703d3d4fbede.json",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/e6a0a51961925fbc37d9b81431449c256ed453f98089eb70f83850f237b4d722.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"aws-cdk-logs-querydefinition-integ.assets"
"aws-cdk-logs-insights-querydefinition-integ.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
Expand All @@ -36,35 +30,88 @@
}
},
"dependencies": [
"aws-cdk-logs-querydefinition-integ.assets"
"aws-cdk-logs-insights-querydefinition-integ.assets"
],
"metadata": {
"/aws-cdk-logs-querydefinition-integ/LogGroup/Resource": [
"/aws-cdk-logs-insights-querydefinition-integ/LogGroup/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "LogGroupF5B46931"
}
],
"/aws-cdk-logs-querydefinition-integ/QueryDefinition/Resource": [
"/aws-cdk-logs-insights-querydefinition-integ/QueryDefinition/Resource": [
{
"type": "aws:cdk:logicalId",
"data": "QueryDefinition4190BC36"
}
],
"/aws-cdk-logs-querydefinition-integ/BootstrapVersion": [
"/aws-cdk-logs-insights-querydefinition-integ/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/aws-cdk-logs-querydefinition-integ/CheckBootstrapVersion": [
"/aws-cdk-logs-insights-querydefinition-integ/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "aws-cdk-logs-querydefinition-integ"
"displayName": "aws-cdk-logs-insights-querydefinition-integ"
},
"LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5.assets": {
"type": "cdk:asset-manifest",
"properties": {
"file": "LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5.assets.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5": {
"type": "aws:cloudformation:stack",
"environment": "aws://unknown-account/unknown-region",
"properties": {
"templateFile": "LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5.template.json",
"validateOnSynth": false,
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
"requiresBootstrapStackVersion": 6,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
"additionalDependencies": [
"LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5.assets"
],
"lookupRole": {
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
"requiresBootstrapStackVersion": 8,
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
}
},
"dependencies": [
"LogsInsightsQueryDefinitionIntegTestDefaultTestDeployAssert902BAAD5.assets"
],
"metadata": {
"/LogsInsightsQueryDefinitionIntegTest/DefaultTest/DeployAssert/BootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "BootstrapVersion"
}
],
"/LogsInsightsQueryDefinitionIntegTest/DefaultTest/DeployAssert/CheckBootstrapVersion": [
{
"type": "aws:cdk:logicalId",
"data": "CheckBootstrapVersion"
}
]
},
"displayName": "LogsInsightsQueryDefinitionIntegTest/DefaultTest/DeployAssert"
},
"Tree": {
"type": "cdk:tree",
"properties": {
"file": "tree.json"
}
}
}
}
Loading

0 comments on commit 86c6f9d

Please sign in to comment.