gpt4 book ai didi

amazon-web-services - 如何使用 cloudform 模板为步骤功能创建 cloudwatch 仪表板

转载 作者:行者123 更新时间:2023-12-03 07:31:50 25 4
gpt4 key购买 nike

我正在尝试使用云形成模板为状态机步骤函数创建云监视仪表板。由于错误“字段 DashboardBody 必须是有效的 JSON 对象”,堆栈创建失败。知道如何传递从模板的参数部分获取的日志组名称吗?

下面是我的云形成模板:

AWSTemplateFormatVersion: 2010-09-09
Description: >-
CloudFormation template to create a dashboard for state functions
Parameters:
DashboardName:
Description: Name of the dashboard to create
Type: String
Default: Test-board
LambdaFunction:
Description: The Lambda function name.
Type: String
Default: test-lambda

StepFunction:
Description: The state function name.
Type: String
Default: MyStateMachine

Resources:
MetricsDashboard:
Type: 'AWS::CloudWatch::Dashboard'
Properties:
DashboardName: !Ref DashboardName
DashboardBody: !Join
- ''
- - >-
{ "widgets": [

{ "type": "log", "x": 6, "y": 6, "width": 18, "height": 3,
"properties": {

"query": "
- !Join
- ""
- "SOURCE '/aws/states/"
- ""
- !Ref StepFunction
- ""
- "' | fields @message\r\n| filter @message like /ERROR/| filter @message like /Exception/ "
- >-
",

"region": "eu-west-1", "stacked": false, "title": "{ Ref:StepFunction},
Step Function Error Logs", "view": "table" } },

{
"type": "metric",
"x": 0,
"y": 0,
"width": 5,
"height": 5,
"properties": {
"view": "singleValue",
"metrics": [
[ "AWS/States", "ExecutionsFailed", "StateMachineArn", "',{ Ref: StepFunction },'" ],
[ ".", "ExecutionsSucceeded", ".", ".", { "color": "#2ca02c" } ],
[ ".", "ExecutionsAborted", ".", ".", { "visible": false, "color": "#ff9896" } ]
],
"stat": "Sum",
"setPeriodToTimeRange": true,
"region": "', { Ref: AWS::Region }, '",
"title": "', "State-Function-", { Ref: StepFunction }," Counts", '",
"period": 300
}
}




]

}

提前致谢,

最佳答案

删除连接,它们最终将成为最终仪表板 json 的一部分。

看看这是否适合您:

AWSTemplateFormatVersion: 2010-09-09
Description: >-
CloudFormation template to create a dashboard for state functions
Parameters:
DashboardName:
Description: Name of the dashboard to create
Type: String
Default: Test-board
LambdaFunction:
Description: The Lambda function name.
Type: String
Default: test-lambda

StepFunction:
Description: The state function name.
Type: String
Default: MyStateMachine

Resources:
MetricsDashboard:
Type: 'AWS::CloudWatch::Dashboard'
Properties:
DashboardName: !Ref DashboardName
DashboardBody: !Sub |
{
"widgets": [
{
"type": "log",
"x": 6,
"y": 6,
"width": 18,
"height": 3,
"properties": {
"query": "SOURCE '/aws/states/${StepFunction}' | fields @message\r\n| filter @message like /ERROR/| filter @message like /Exception/ ",
"region": "eu-west-1",
"stacked": false,
"title": "${StepFunction} Step Function Error Logs",
"view": "table"
}
},
{
"type": "metric",
"x": 0,
"y": 0,
"width": 5,
"height": 5,
"properties": {
"view": "singleValue",
"metrics": [
[
"AWS/States",
"ExecutionsFailed",
"StateMachineArn",
"${StepFunction}"
],
[
".",
"ExecutionsSucceeded",
".",
".",
{
"color": "#2ca02c"
}
],
[
".",
"ExecutionsAborted",
".",
".",
{
"visible": false,
"color": "#ff9896"
}
]
],
"stat": "Sum",
"setPeriodToTimeRange": true,
"region": "${AWS::Region}",
"title": "State Function ${StepFunction} Counts",
"period": 300
}
}
]
}

关于amazon-web-services - 如何使用 cloudform 模板为步骤功能创建 cloudwatch 仪表板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60642807/

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