-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lambda): support for advanced logging (#28039)
Structured logging enables automated analysis of the logs, thus enables customers to perform quick exploratory and automated monitoring the health of their applications, and helps them troubleshoot their production issues faster. Structured logging is now considered to be a monitoring best practice. Lambda is developing Advance Logging Controls to give developers and operators more control over their function logs. The feature allows customers to capture logs in JSON format and control the level of details in emitted logs. To ensure compatibility and enable these capabilities, four new fields (LogFormat, ApplicationLogLevel, SystemLogLevel, and LogGroup) will be added to the existing LoggingConfig structure. Also, even adding custom log group for Log group section to have the flexibility of changing the name instead of having it as default. This update empowers customers to define their logging behavior and efficiently manage their function logs, reflecting Lambda's commitment to delivering a user-friendly logging solution that addresses the evolving needs of users. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
1d1876c
commit 3278c19
Showing
13 changed files
with
2,101 additions
and
3 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ws-lambda/test/integ.logging-config.js.snapshot/aws-cdk-lambda-logging-config.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
326 changes: 326 additions & 0 deletions
326
...-lambda/test/integ.logging-config.js.snapshot/aws-cdk-lambda-logging-config.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,326 @@ | ||
{ | ||
"Resources": { | ||
"MyLogGroupWithLogGroupNameB577EB65": { | ||
"Type": "AWS::Logs::LogGroup", | ||
"Properties": { | ||
"LogGroupName": "customLogGroup", | ||
"RetentionInDays": 731 | ||
}, | ||
"UpdateReplacePolicy": "Retain", | ||
"DeletionPolicy": "Retain" | ||
}, | ||
"LambdaWithLogGroupServiceRoleC5DDB031": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaWithLogGroupC3B62A1A": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "foo" | ||
}, | ||
"Handler": "index.handler", | ||
"LoggingConfig": { | ||
"LogGroup": { | ||
"Ref": "MyLogGroupWithLogGroupNameB577EB65" | ||
} | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaWithLogGroupServiceRoleC5DDB031", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"LambdaWithLogGroupServiceRoleC5DDB031" | ||
] | ||
}, | ||
"MyLogGroupWithoutLogGroupName385E46B7": { | ||
"Type": "AWS::Logs::LogGroup", | ||
"Properties": { | ||
"RetentionInDays": 731 | ||
}, | ||
"UpdateReplacePolicy": "Retain", | ||
"DeletionPolicy": "Retain" | ||
}, | ||
"LambdaWithLogGroupAndNoLogGroupNameServiceRoleFEE6AF87": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaWithLogGroupAndNoLogGroupName1F5C7375": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "foo" | ||
}, | ||
"Handler": "index.handler", | ||
"LoggingConfig": { | ||
"LogGroup": { | ||
"Ref": "MyLogGroupWithoutLogGroupName385E46B7" | ||
} | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaWithLogGroupAndNoLogGroupNameServiceRoleFEE6AF87", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"LambdaWithLogGroupAndNoLogGroupNameServiceRoleFEE6AF87" | ||
] | ||
}, | ||
"LambdaWithTextFormatServiceRoleABCC0E93": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaWithTextFormatA0EDE227": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "foo" | ||
}, | ||
"Handler": "index.handler", | ||
"LoggingConfig": { | ||
"LogFormat": "Text" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaWithTextFormatServiceRoleABCC0E93", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"LambdaWithTextFormatServiceRoleABCC0E93" | ||
] | ||
}, | ||
"LambdaWithJSONFormatServiceRole37FFB486": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaWithJSONFormat20E01C00": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "foo" | ||
}, | ||
"Handler": "index.handler", | ||
"LoggingConfig": { | ||
"LogFormat": "JSON" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaWithJSONFormatServiceRole37FFB486", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"LambdaWithJSONFormatServiceRole37FFB486" | ||
] | ||
}, | ||
"LambdaWithLogLevelServiceRole90A45743": { | ||
"Type": "AWS::IAM::Role", | ||
"Properties": { | ||
"AssumeRolePolicyDocument": { | ||
"Statement": [ | ||
{ | ||
"Action": "sts:AssumeRole", | ||
"Effect": "Allow", | ||
"Principal": { | ||
"Service": "lambda.amazonaws.com" | ||
} | ||
} | ||
], | ||
"Version": "2012-10-17" | ||
}, | ||
"ManagedPolicyArns": [ | ||
{ | ||
"Fn::Join": [ | ||
"", | ||
[ | ||
"arn:", | ||
{ | ||
"Ref": "AWS::Partition" | ||
}, | ||
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole" | ||
] | ||
] | ||
} | ||
] | ||
} | ||
}, | ||
"LambdaWithLogLevelCBBBEFFC": { | ||
"Type": "AWS::Lambda::Function", | ||
"Properties": { | ||
"Code": { | ||
"ZipFile": "foo" | ||
}, | ||
"Handler": "index.handler", | ||
"LoggingConfig": { | ||
"ApplicationLogLevel": "INFO", | ||
"LogFormat": "JSON", | ||
"SystemLogLevel": "INFO" | ||
}, | ||
"Role": { | ||
"Fn::GetAtt": [ | ||
"LambdaWithLogLevelServiceRole90A45743", | ||
"Arn" | ||
] | ||
}, | ||
"Runtime": "nodejs18.x" | ||
}, | ||
"DependsOn": [ | ||
"LambdaWithLogLevelServiceRole90A45743" | ||
] | ||
} | ||
}, | ||
"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." | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...cdk-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/cdk.out
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
...-testing/framework-integ/test/aws-lambda/test/integ.logging-config.js.snapshot/integ.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
...logging-config.js.snapshot/lambdaloggingconfigDefaultTestDeployAssert24012B25.assets.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.