gpt4 book ai didi

aws-cloudformation - 如何在 Cloudwatch 仪表板小部件模板中引用特定的 AWS::StateMachine?

转载 作者:行者123 更新时间:2023-12-03 07:45:33 26 4
gpt4 key购买 nike

我的 Cloudformation 模板中有一个可运行的 Cloudwatch 仪表板小部件,用于 Lambda 函数,例如,

---
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
MyLambda:
Type: AWS::Serverless::Function
...

MyStateMachine:
Type: "AWS::StepFunctions::StateMachine"
...

MyDashboard:
Type: AWS::CloudWatch::Dashboard
Properties:
DashboardName: MyDashboard
DashboardBody:
Fn::Sub: '{
"widgets": [
{
"type": "metric",
"x": 0,
"y": 3,
"width": 24,
"height": 3,
"properties": {
"view": "singleValue",
"metrics": [
[ "AWS/Lambda", "Invocations", "FunctionName", "${MyLambda}", { "stat": "Sum", "period": 86400 } ],
[ ".", "Duration", ".", ".", { "stat": "Average", "period": 86400, "color": "#2ca02c" } ],
[ ".", "Errors", ".", ".", { "stat": "Sum", "period": 86400, "color": "#d62728" } ],
[ ".", "Throttles", ".", ".", { "stat": "Sum", "period": 86400, "color": "#ff7f0e" } ]
],
"region": "us-west-2",
"title": "MyLambda",
"stacked": true
}
}
]
}'

我想向此仪表板添加 MyStateMachine 小部件,但我不知道如何编写相当于的状态机,

[ "AWS/Lambda", "Invocations", "FunctionName", "${MyLambda}", { "stat": "Sum", "period": 86400 } ]

我发现调用了 AWS/Lambda 并且 AWS Namespace等效的一个是 AWS/States 我发现 all the options我可以使用Invokings,但我不知道如何替换FunctionNameThis建议我可以使用 InstanceId,但除此之外的文档有限。

如何为我的状态机创建 AWS Cloudwatch 仪表板小组件?

最佳答案

我通过在 AWS Web 控制台中制作小部件,然后查看它生成的源代码来解决这个问题。以下内容对我有用。

                      "title": "MyLambda",
"stacked": true
}
+ },
+ {
+ "type": "metric",
+ "x": 0,
+ "y": 9,
+ "width": 24,
+ "height": 3,
+ "properties": {
+ "view": "timeSeries",
+ "metrics": [
+ [ "AWS/States", "ActivitiesStarted", "ActivityArn", "${MyStateMachine}", { "stat": "Sum", "period": 86400 } ]
+ ],
+ "region": "us-west-2",
+ "title": "State Machine Metrics",
+ "period": 300
+ }
}
]
}'

关于aws-cloudformation - 如何在 Cloudwatch 仪表板小部件模板中引用特定的 AWS::StateMachine?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47639542/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com