How divide Log Group by each Lambda function alias?

0

Hello, guys.

Thank you for your help in advance.

I have a question, how divide Log Group by each Lambda function alias?
For example, there is the following Lambda function and aliases.

  • Lambda function
    testFunctionKoki

  • Lambda function aliases
    dev
    test
    pro

I would like to create Log Group by each alias using boto3 or AWS CLI when creating Lambda function alias, and to relate each Log Group and each alias.
Such as this.

  • When creating dev alias, creating Log Group that is '/aws/lambda/testFunctionKoki:dev'.
  • When testFunctionKoki that alias is dev has executed, outputting any logs to '/aws/lambda/testFunctionKoki:dev'.

How can I do this?
I am looking for any answers.
Thank you.

Edited by: koki-n on Jun 14, 2020 6:46 PM

koki-n
已提问 4 年前1295 查看次数
1 回答
0

Hello,

Lambda does not provide a way to specify a custom log group target. A log group is automatically created on the first invocation of a Lambda and the log group name will contain the name of the Lambda function.

When log streams are created however, the function version is prefixed onto the name of the log stream. You can use a log stream filter to view log streams for a specific version.

If you want to know which alias invoked a particular version of a Lambda, the alias ARN is included in the Lambda context object as: context.invoked_function_arn You can use the print method to write the ARN into the log event.

Best,
Kevin

AWS
已回答 4 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则