如何在AWS中分配动态资产ID站点监视仪表板定义云形式?

发布于 2025-01-22 05:05:48 字数 4877 浏览 5 评论 0原文

我们创建了一个云形式模板,用于自动实现AWS站点监视仪表板。我们想在下面的仪表板定义中动态地引用并分配资产逻辑ID。

{\"widgets\":[{\"type\":\"sc-line-chart\",\"title\":\"power_all_plants_5m\",\"x\":0,\"y\":0,\"height\":3,\"width\":3,\"metrics\":[{\"type\":\"iotsitewise\",\"label\":\"power_all_plants_5m (All Power Plants)\",\"assetId\":\"0cd25cb9-89f9-4a93-b2bf-88050436f700\",\"propertyId\":\"fd34bba7-4ea2-4d62-9058-ab78b726b61a\",\"dataType\":\"DOUBLE\"}],\"alarms\":[],\"properties\":{\"colorDataAcrossThresholds\":true},\"annotations\":{\"y\":[]}},{\"type\":\"sc-line-chart\",\"title\":\"Generator-1\",\"x\":3,\"y\":0,\"height\":3,\"width\":3,\"metrics\":[{\"type\":\"iotsitewise\",\"label\":\"sum_watts_5m (Generator-1)\",\"assetId\":\"45b97aaa-3f0c-4312-a8a5-a00e4da8ec37\",\"propertyId\":\"e22d9a23-4ac8-432a-816b-cc4a2138b287\",\"dataType\":\"DOUBLE\"},{\"type\":\"iotsitewise\",\"label\":\"rpm (Generator-1)\",\"assetId\":\"45b97aaa-3f0c-4312-a8a5-a00e4da8ec37\",\"propertyId\":\"c6a40902-f07b-40ba-b6c5-3509b069dd4c\",\"dataType\":\"DOUBLE\"}],\"alarms\":[],\"properties\":{\"colorDataAcrossThresholds\":true},\"annotations\":{\"y\":[]}},{\"type\":\"sc-line-chart\",\"title\":\"Generator-2\",\"x\":0,\"y\":3,\"height\":3,\"width\":3,\"metrics\":[{\"type\":\"iotsitewise\",\"label\":\"sum_watts_5m (Generator-2)\",\"assetId\":\"b999319c-20ec-4060-b3b7-bc5ce7ef189c\",\"propertyId\":\"e22d9a23-4ac8-432a-816b-cc4a2138b287\",\"dataType\":\"DOUBLE\"},{\"type\":\"iotsitewise\",\"label\":\"rpm (Generator-2)\",\"assetId\":\"b999319c-20ec-4060-b3b7-bc5ce7ef189c\",\"propertyId\":\"c6a40902-f07b-40ba-b6c5-3509b069dd4c\",\"dataType\":\"DOUBLE\"}],\"alarms\":[],\"properties\":{\"colorDataAcrossThresholds\":true},\"annotations\":{\"y\":[]}}]}

通过添加向后斜线()以及双引号,将此JSON的字面形式转换为YAML,因为我们将YAML用作CloudFormation模板的默认语言,否则看起来如下。

{
  "widgets": [
    {
      "type": "sc-line-chart",
      "title": "power_all_plants_5m",
      "x": 0,
      "y": 0,
      "height": 3,
      "width": 3,
      "metrics": [
        {
          "type": "iotsitewise",
          "label": "power_all_plants_5m (All Power Plants)",
          "assetId": "0cd25cb9-89f9-4a93-b2bf-88050436f700",
          "propertyId": "fd34bba7-4ea2-4d62-9058-ab78b726b61a",
          "dataType": "DOUBLE"
        }
      ],
      "alarms": [],
      "properties": {
        "colorDataAcrossThresholds": true
      },
      "annotations": {
        "y": []
      }
    },
    {
      "type": "sc-line-chart",
      "title": "Generator-1",
      "x": 3,
      "y": 0,
      "height": 3,
      "width": 3,
      "metrics": [
        {
          "type": "iotsitewise",
          "label": "sum_watts_5m (Generator-1)",
          "assetId": "45b97aaa-3f0c-4312-a8a5-a00e4da8ec37",
          "propertyId": "e22d9a23-4ac8-432a-816b-cc4a2138b287",
          "dataType": "DOUBLE"
        },
        {
          "type": "iotsitewise",
          "label": "rpm (Generator-1)",
          "assetId": "45b97aaa-3f0c-4312-a8a5-a00e4da8ec37",
          "propertyId": "c6a40902-f07b-40ba-b6c5-3509b069dd4c",
          "dataType": "DOUBLE"
        }
      ],
      "alarms": [],
      "properties": {
        "colorDataAcrossThresholds": true
      },
      "annotations": {
        "y": []
      }
    },
    {
      "type": "sc-line-chart",
      "title": "Generator-2",
      "x": 0,
      "y": 3,
      "height": 3,
      "width": 3,
      "metrics": [
        {
          "type": "iotsitewise",
          "label": "sum_watts_5m (Generator-2)",
          "assetId": "b999319c-20ec-4060-b3b7-bc5ce7ef189c",
          "propertyId": "e22d9a23-4ac8-432a-816b-cc4a2138b287",
          "dataType": "DOUBLE"
        },
        {
          "type": "iotsitewise",
          "label": "rpm (Generator-2)",
          "assetId": "b999319c-20ec-4060-b3b7-bc5ce7ef189c",
          "propertyId": "c6a40902-f07b-40ba-b6c5-3509b069dd4c",
          "dataType": "DOUBLE"
        }
      ],
      "alarms": [],
      "properties": {
        "colorDataAcrossThresholds": true
      },
      "annotations": {
        "y": []
      }
    }
  ]
}

我们想使用预先创建的资产动态分配资产ID。我们尝试了以下变化,但没有命运。

现有值 - > 0CD25CB9-89F9-4A93-B2BF-88050436F700

尝试以下更改: -

[{\"Ref\":\"GeneratorAsset\"}]
!Ref GeneratorAsset
\"!Ref GeneratorAsset\"
{\"Ref\":GeneratorAsset}
{\"Ref\":\"GeneratorAsset\"}
\"{\"Ref\":\"GeneratorAsset\"}\"
\"{\"Fn::Sub\":${GeneratorAsset}}\"
\"{\"Fn::Sub\":${!GeneratorAsset}}\"
\"{\"Fn::Sub\":${!GeneratorAsset} }\"

此处GeneratorAsaters是在仪表板之前已经创建的资源。请求任何云形式专家,以帮助我们用正确的动态字符串替换ID值。

参考链接: - https:https:https:// docs。 aws.amazon.com/awscloudformation/latest/userguide/aws-resource-iotsitewise-dashboard.html

We created a Cloudformation template for auto implementation of the AWS Sitewise monitoring dashboard. We would like to dynamically refer and assign the Asset logical id inside the below dashboard definition.

{\"widgets\":[{\"type\":\"sc-line-chart\",\"title\":\"power_all_plants_5m\",\"x\":0,\"y\":0,\"height\":3,\"width\":3,\"metrics\":[{\"type\":\"iotsitewise\",\"label\":\"power_all_plants_5m (All Power Plants)\",\"assetId\":\"0cd25cb9-89f9-4a93-b2bf-88050436f700\",\"propertyId\":\"fd34bba7-4ea2-4d62-9058-ab78b726b61a\",\"dataType\":\"DOUBLE\"}],\"alarms\":[],\"properties\":{\"colorDataAcrossThresholds\":true},\"annotations\":{\"y\":[]}},{\"type\":\"sc-line-chart\",\"title\":\"Generator-1\",\"x\":3,\"y\":0,\"height\":3,\"width\":3,\"metrics\":[{\"type\":\"iotsitewise\",\"label\":\"sum_watts_5m (Generator-1)\",\"assetId\":\"45b97aaa-3f0c-4312-a8a5-a00e4da8ec37\",\"propertyId\":\"e22d9a23-4ac8-432a-816b-cc4a2138b287\",\"dataType\":\"DOUBLE\"},{\"type\":\"iotsitewise\",\"label\":\"rpm (Generator-1)\",\"assetId\":\"45b97aaa-3f0c-4312-a8a5-a00e4da8ec37\",\"propertyId\":\"c6a40902-f07b-40ba-b6c5-3509b069dd4c\",\"dataType\":\"DOUBLE\"}],\"alarms\":[],\"properties\":{\"colorDataAcrossThresholds\":true},\"annotations\":{\"y\":[]}},{\"type\":\"sc-line-chart\",\"title\":\"Generator-2\",\"x\":0,\"y\":3,\"height\":3,\"width\":3,\"metrics\":[{\"type\":\"iotsitewise\",\"label\":\"sum_watts_5m (Generator-2)\",\"assetId\":\"b999319c-20ec-4060-b3b7-bc5ce7ef189c\",\"propertyId\":\"e22d9a23-4ac8-432a-816b-cc4a2138b287\",\"dataType\":\"DOUBLE\"},{\"type\":\"iotsitewise\",\"label\":\"rpm (Generator-2)\",\"assetId\":\"b999319c-20ec-4060-b3b7-bc5ce7ef189c\",\"propertyId\":\"c6a40902-f07b-40ba-b6c5-3509b069dd4c\",\"dataType\":\"DOUBLE\"}],\"alarms\":[],\"properties\":{\"colorDataAcrossThresholds\":true},\"annotations\":{\"y\":[]}}]}

This JSON literal is converted to YAML by adding backward slashes () along with the double quotes because we are using YAML as the default language of the Cloudformation template otherwise it looks like the below.

{
  "widgets": [
    {
      "type": "sc-line-chart",
      "title": "power_all_plants_5m",
      "x": 0,
      "y": 0,
      "height": 3,
      "width": 3,
      "metrics": [
        {
          "type": "iotsitewise",
          "label": "power_all_plants_5m (All Power Plants)",
          "assetId": "0cd25cb9-89f9-4a93-b2bf-88050436f700",
          "propertyId": "fd34bba7-4ea2-4d62-9058-ab78b726b61a",
          "dataType": "DOUBLE"
        }
      ],
      "alarms": [],
      "properties": {
        "colorDataAcrossThresholds": true
      },
      "annotations": {
        "y": []
      }
    },
    {
      "type": "sc-line-chart",
      "title": "Generator-1",
      "x": 3,
      "y": 0,
      "height": 3,
      "width": 3,
      "metrics": [
        {
          "type": "iotsitewise",
          "label": "sum_watts_5m (Generator-1)",
          "assetId": "45b97aaa-3f0c-4312-a8a5-a00e4da8ec37",
          "propertyId": "e22d9a23-4ac8-432a-816b-cc4a2138b287",
          "dataType": "DOUBLE"
        },
        {
          "type": "iotsitewise",
          "label": "rpm (Generator-1)",
          "assetId": "45b97aaa-3f0c-4312-a8a5-a00e4da8ec37",
          "propertyId": "c6a40902-f07b-40ba-b6c5-3509b069dd4c",
          "dataType": "DOUBLE"
        }
      ],
      "alarms": [],
      "properties": {
        "colorDataAcrossThresholds": true
      },
      "annotations": {
        "y": []
      }
    },
    {
      "type": "sc-line-chart",
      "title": "Generator-2",
      "x": 0,
      "y": 3,
      "height": 3,
      "width": 3,
      "metrics": [
        {
          "type": "iotsitewise",
          "label": "sum_watts_5m (Generator-2)",
          "assetId": "b999319c-20ec-4060-b3b7-bc5ce7ef189c",
          "propertyId": "e22d9a23-4ac8-432a-816b-cc4a2138b287",
          "dataType": "DOUBLE"
        },
        {
          "type": "iotsitewise",
          "label": "rpm (Generator-2)",
          "assetId": "b999319c-20ec-4060-b3b7-bc5ce7ef189c",
          "propertyId": "c6a40902-f07b-40ba-b6c5-3509b069dd4c",
          "dataType": "DOUBLE"
        }
      ],
      "alarms": [],
      "properties": {
        "colorDataAcrossThresholds": true
      },
      "annotations": {
        "y": []
      }
    }
  ]
}

We would like to assign Asset ID dynamically using "!Ref" with pre-created Asset. We have tried the below variations but no fate.

Existing value -> 0cd25cb9-89f9-4a93-b2bf-88050436f700

Tried below changes:-

[{\"Ref\":\"GeneratorAsset\"}]
!Ref GeneratorAsset
\"!Ref GeneratorAsset\"
{\"Ref\":GeneratorAsset}
{\"Ref\":\"GeneratorAsset\"}
\"{\"Ref\":\"GeneratorAsset\"}\"
\"{\"Fn::Sub\":${GeneratorAsset}}\"
\"{\"Fn::Sub\":${!GeneratorAsset}}\"
\"{\"Fn::Sub\":${!GeneratorAsset} }\"

Here GeneratorAsset is a resource that is already created before Dashboard. Request any Cloudformation expert to help us replace the id value with the correct dynamic string.

Ref link:- https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iotsitewise-dashboard.html

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文