启用 Lambda 洞察v4.0.61
您可以为您的 Remotion Lambda 函数启用AWS Lambda 洞察。
先决条件
1 确保您至少使用 Remotion v4.0.61。
2 如果您在 v4.0.61 之前开始使用 Remotion,请更新您的AWS 用户权限和AWS 角色权限,因为现在需要更多权限。
启用 Lambda 洞察
通过 CLI:
npx remotion lambda functions deploy --enable-lambda-insights
npx remotion lambda functions deploy --enable-lambda-insights
如果函数已存在,请先删除它。
通过 Node.js APIs:
deploy.tstsx
import {deployFunction } from "@remotion/lambda";const {alreadyExisted } = awaitdeployFunction ({createCloudWatchLogGroup : true,region : "us-east-1",timeoutInSeconds : 120,memorySizeInMb : 3009,enableLambdaInsights : true,});// Note: If the function previously already existed, Lambda insights are not applied.// Delete the old function and deploy again.assert (!alreadyExisted );
deploy.tstsx
import {deployFunction } from "@remotion/lambda";const {alreadyExisted } = awaitdeployFunction ({createCloudWatchLogGroup : true,region : "us-east-1",timeoutInSeconds : 120,memorySizeInMb : 3009,enableLambdaInsights : true,});// Note: If the function previously already existed, Lambda insights are not applied.// Delete the old function and deploy again.assert (!alreadyExisted );
为 Lambda 函数添加角色
为了实际允许 Lambda 将数据发送到 CloudWatch,您需要执行以下操作:
- 转到 Lambda 仪表板并选择任何 Remotion Lambda 函数。
- 在“配置”选项卡中,向下滚动到“监控和运维工具”,在“附加监控工具”部分,单击“编辑”。
- 切换开关以启用“启用 AWS Lambda 洞察”。如果已经打开,请关闭它,保存,然后再次启用。
这将向 Lambda 函数的角色添加必要的权限。
所有 Lambda 函数在默认设置下共享相同的角色,因此您只需要执行一次此操作。
查看 Lambda 洞察
在您的 CloudWatch 仪表板(us-east-1
的链接)下的 Insights ➞ Lambda Insights ➞ 单个函数,您可以查看 Remotion Lambda 函数的指标。
renderMediaOnLambda()
的返回值中还包含了 Lambda 洞察的链接。
如果您通过 CLI 使用 --log=verbose
标志进行渲染,无论是否启用 Lambda 洞察,都会打印 Lambda 洞察的链接。