CloudWatch仪表板的云形式子功能

发布于 2025-01-25 02:43:36 字数 2983 浏览 0 评论 0原文

我使用AWS :: Region pseudoparameter在我的CloudWatch仪表板仪表板(确保我的堆栈不可知)中使用! 给出以下

  OrderDashboard:
    Type: AWS::CloudWatch::Dashboard
    Properties:
      DashboardBody:  !Sub  '{  "widgets": [    {      "type": "metric",      "x": 6,      "y": 0,      "width": 6,      "height": 6,      "properties": {        "metrics": [          [ "address", "validateAddressApiLatency" ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "title": "ValidateAddressApiSuccessLatencyP99",        "period": 300,        "stat": "p99"      }    },    {      "type": "metric",      "x": 12,      "y": 0,      "width": 8,      "height": 6,      "properties": {        "metrics": [          [ "address", "validateAddressApiErrorLatency" ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "title": "ValidateAddressApiErrorLatencyP99",        "period": 300,        "stat": "p99"      }    },    {      "type": "text",      "x": 0,      "y": 0,      "width": 6,      "height": 6,      "properties": {        "markdown": "# Heading \nThis dashboard exists to show that our success latency metric and error latency metric are published successfully using a single annotation and aspectj.\n\nThe first row shows the 99th percentile latencies, and the bottom column shows the count of the number of calls"      }    },    {      "type": "metric",      "x": 6,      "y": 6,      "width": 6,      "height": 6,      "properties": {        "metrics": [          [ { "expression": "SELECT COUNT(validateAddressApiLatency) FROM SCHEMA(address)", "label": "NumberOfSuccessfulCalls", "id": "q1", "region": "${AWS::Region}" } ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "stat": "Average",        "period": 300,        "title": "NumberOfSuccessfulValidateCalls"      }    },    {      "type": "metric",      "x": 12,      "y": 6,      "width": 6,      "height": 6,      "properties": {        "metrics": [          [ { "expression": "SELECT COUNT(validateAddressApiErrorLatency) FROM SCHEMA(address)", "label": "NumberOfErroredCalls", "id": "q1", "region": "${AWS::Region}" } ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "stat": "Average",        "period": 300,        "title": "NumberOfErrorValidateCalls"     }    }  ]}'
      DashboardName: order-dashboard

我正在使用的云形式在我部署仪表板时

有趣的是,我将sub与模板中的其他位置进行区域参数一起使用。

Outputs:
  OrderApiUrl:
    Description: "The endpoint you can use to place orders.  Make sure to append the order id to the end"
    Value: !Sub "https://${OrderApi}.execute-api.${AWS::Region}.amazonaws.com/v1/orders/"

关于我可以做什么以替换价值的想法吗?谢谢

I'm running into issues using the !Sub intrinsic cloudformation function with AWS::Region pseudoparameter within the body of my cloudwatch dashboard (to ensure my stack is region agnostic). The cloudformation I am using is given below

  OrderDashboard:
    Type: AWS::CloudWatch::Dashboard
    Properties:
      DashboardBody:  !Sub  '{  "widgets": [    {      "type": "metric",      "x": 6,      "y": 0,      "width": 6,      "height": 6,      "properties": {        "metrics": [          [ "address", "validateAddressApiLatency" ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "title": "ValidateAddressApiSuccessLatencyP99",        "period": 300,        "stat": "p99"      }    },    {      "type": "metric",      "x": 12,      "y": 0,      "width": 8,      "height": 6,      "properties": {        "metrics": [          [ "address", "validateAddressApiErrorLatency" ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "title": "ValidateAddressApiErrorLatencyP99",        "period": 300,        "stat": "p99"      }    },    {      "type": "text",      "x": 0,      "y": 0,      "width": 6,      "height": 6,      "properties": {        "markdown": "# Heading \nThis dashboard exists to show that our success latency metric and error latency metric are published successfully using a single annotation and aspectj.\n\nThe first row shows the 99th percentile latencies, and the bottom column shows the count of the number of calls"      }    },    {      "type": "metric",      "x": 6,      "y": 6,      "width": 6,      "height": 6,      "properties": {        "metrics": [          [ { "expression": "SELECT COUNT(validateAddressApiLatency) FROM SCHEMA(address)", "label": "NumberOfSuccessfulCalls", "id": "q1", "region": "${AWS::Region}" } ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "stat": "Average",        "period": 300,        "title": "NumberOfSuccessfulValidateCalls"      }    },    {      "type": "metric",      "x": 12,      "y": 6,      "width": 6,      "height": 6,      "properties": {        "metrics": [          [ { "expression": "SELECT COUNT(validateAddressApiErrorLatency) FROM SCHEMA(address)", "label": "NumberOfErroredCalls", "id": "q1", "region": "${AWS::Region}" } ]        ],        "view": "timeSeries",        "stacked": false,        "region": "${AWS::Region}",        "stat": "Average",        "period": 300,        "title": "NumberOfErrorValidateCalls"     }    }  ]}'
      DashboardName: order-dashboard

When I deploy the dashboard, the region is not substituted
enter image description here

The interesting thing is I use sub with the region parameter other places in the template, it works.

Outputs:
  OrderApiUrl:
    Description: "The endpoint you can use to place orders.  Make sure to append the order id to the end"
    Value: !Sub "https://${OrderApi}.execute-api.${AWS::Region}.amazonaws.com/v1/orders/"

Any idea on what I can do to get the value substituted? Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟火散人牵绊 2025-02-01 02:43:36

我同意@erikasplund,类似:

  OrderDashboard:
    Type: AWS::CloudWatch::Dashboard
    Properties:
      DashboardName: order-dashboard
      DashboardBody: !Sub |
        {
          "widgets": [
            {
              "properties": {
                "metrics": [
                  "AWS/Lambda",
                  "Duration",
                  "FunctionName",
                  "${MyReference}"
                ]
              }
            }
        }

I agree with @ErikAsplund, something like:

  OrderDashboard:
    Type: AWS::CloudWatch::Dashboard
    Properties:
      DashboardName: order-dashboard
      DashboardBody: !Sub |
        {
          "widgets": [
            {
              "properties": {
                "metrics": [
                  "AWS/Lambda",
                  "Duration",
                  "FunctionName",
                  "${MyReference}"
                ]
              }
            }
        }
一抹微笑 2025-02-01 02:43:36

您提供的的代码效果很好。因此,在问题中,您必须与其他因素有关的问题必须与其他因素有关。

也许您正在使用其他代码,而不是问题中的代码。

The code that you provided works perfectly fine. Thus the issue that you have must be related to other factors than your CloudFormation code in the question.

Maybe you are using some other code, not the one in the question.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文