使用 JSON 结构创建 Cloudwatch 仪表板时,"Latest value" 和 "Time range value" 的等效项是什么

What is the equivalent of "Latest value" and "Time range value" when creating a Cloudwatch dashboard using the JSON structure

鉴于此 cloudwatch 仪表板 json 片段:

{
  "type": "metric",
  "x": 3,
  "y": 0,
  "width": 3,
  "height": 3,
  "properties": {
    "metrics": [
      [
        "AWS/ApiGateway",
        "Count",
        "ApiName",
        "my-api",
        {
          "stat": "Sum"
        }
      ]
    ],
    "view": "singleValue",
    "region": "eu-west-1",
    "period": 300,
    "title": "Number of api calls"
  }
}

小部件默认显示 "Latest value"。我想按照下面的屏幕截图查看 "Time range value"。如何使用 cloudwatch 仪表板指定该设置 json?

将此添加到 properties 对象:

"setPeriodToTimeRange": true

在你的例子中:

{
  "type": "metric",
  "x": 3,
  "y": 0,
  "width": 3,
  "height": 3,
  "properties": {
    "metrics": [
      [
        "AWS/ApiGateway",
        "Count",
        "ApiName",
        "my-api",
        {
          "stat": "Sum"
        }
      ]
    ],
    "view": "singleValue",
    "region": "eu-west-1",
    "period": 300,
    "title": "Number of api calls",
    "setPeriodToTimeRange": true
  }
}