Skip to content

Lambda custom log group

0

Hi, I have a group of functions with name likes fonction-a, fonction-b. By default lambda create a log group /aws/lambda/function-a, etc.. As I would like to have all the log in the same log group, I created a log group /aws/lambda/function but when I create for example the function-a, when I try to enter /aws/lambda/function in the cusom log group field, the field is deleted, no way to enter this name in the field, as soon as I entered the second slash, or past the log name, the content of field field is automaticaly deleted, why??? Thank you Regards

  • please accept the answer if it was helpful

asked a year ago488 views
4 Answers
0

Hi Oleksii, Thank you for your answer but this not explain why I could not enter in the custom log group field my log group with the name : /aws/lambda/function. Regards Franck

answered a year ago
0

https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs.html

By default, Lambda sends logs to a log group named /aws/lambda/<function name>. If you want your function to send logs to another group, you can configure this using the Lambda console, the AWS Command Line Interface (AWS CLI) or the Lambda API. See Configuring CloudWatch log groups to learn more.

https://docs.aws.amazon.com/lambda/latest/dg/monitoring-cloudwatchlogs-advanced.html#monitoring-cloudwatchlogs-loggroups

You can configure multiple Lambda functions to send logs to the same CloudWatch log group. For example, you could use a single log group to store logs for all of the Lambda functions that make up a particular application. When you use a custom log group for a Lambda function, the log streams Lambda creates include the function name and function version. This ensures that the mapping between log messages and functions is preserved, even if you use the same log group for multiple functions.

The log stream naming format for custom log groups follows this convention:

YYYY/MM/DD/<function_name>[<function_version>][<execution_environment_GUID>]
EXPERT
answered a year ago
0

Hello, Thank Oleksii for your help. But between I renamed my log group MyName to make it working, but I discover that CloudFront still want to create a log group in another country with /aws/lambda/us-east-1.<function name> even if my log group name is MyName and not /aws/lambda/MyName. So if it's help someone, when you want create your custom log group for several function with a name xxxx, to make CloudFront working correctly put that in your permission policy: { "Sid": "CreateLogs", "Effect": "Allow", "Action": [ "logs:CreateLogGroup" ], "Resource": [ "arn:aws:logs::<account_ID>:" ] }, { "Sid": "WriteLogs", "Effect": "Allow", "Action": [ "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": "arn:aws:logs::<account_ID>:log-group:" } You must put * instead of the us-east-1 region and you must end with log-group:* instead of the log group name, and then it works perfectly. I think that there is a bug with a custom name... Regards Franck

answered a year ago
0

Found an another bug, my log group I created is with a 3 months retention, and when CloudFront created a new log group in another country it sets it with never expire retention period, that not great that it doesn't take the valur from the origin one... Regards Franck

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.