

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在 中管理資料儲存 AWS IoT SiteWise
<a name="manage-data-storage"></a>

您可以設定 AWS IoT SiteWise 將資料儲存在下列儲存層：

**熱層**  
 熱儲存層是 AWS IoT SiteWise 受管時間序列儲存。熱層對經常存取的資料最有效，具有低write-to-read延遲。存放在熱層中的資料供需要快速存取設備中最新測量值的工業應用程式使用。這包括使用互動式儀表板視覺化即時指標的應用程式，或監控操作和啟動警示以識別效能問題的應用程式。  
根據預設，擷取至 的資料 AWS IoT SiteWise 會存放在熱層中。您可以定義熱層的保留期間，之後會根據您的組態，將熱層中的資料 AWS IoT SiteWise 移至暖層或冷層儲存。為了獲得最佳效能和成本效益，請將熱方案保留期設定為比經常擷取資料所花費的時間更長。這用於即時指標、警示和監控案例。如果未設定保留期間，您的資料將無限期儲存在熱層中。

**暖層**  
 暖儲存層是 AWS IoT SiteWise 受管層，可有效以經濟實惠的方式儲存歷史資料。它最適合用於擷取具有中等write-to-read延遲特性的大量資料。使用暖層來存放大型工作負載所需的歷史資料。例如，它用於分析、商業智慧應用程式 (BI)、報告工具和機器學習 (ML) 模型訓練的資料擷取。如果您啟用冷儲存層，您可以定義暖層保留期。保留期間結束後， 會從暖層 AWS IoT SiteWise 刪除資料。

**冷層**  
冷儲存層使用 Amazon S3 儲存貯體來存放很少使用的資料。啟用冷層後， AWS IoT SiteWise 會每 6 小時複寫一次時間序列，包括測量、指標、轉換和彙總，以及資產模型定義。冷層用於存放可容忍歷史報告和備份高讀取延遲的資料。

**Topics**
+ [在 中設定儲存體設定 AWS IoT SiteWise](configure-storage.md)
+ [對 的儲存設定進行故障診斷 AWS IoT SiteWise](troubleshoot-storage-configuration.md)
+ [儲存在冷層中的資料檔案路徑和結構描述](file-path-and-schema.md)

# 在 中設定儲存體設定 AWS IoT SiteWise
<a name="configure-storage"></a>

您可以設定儲存設定來選擇加入服務受管暖層儲存，也可以將資料複寫到冷層。若要進一步了解暖層和熱層的保留期間，請參閱 [資料保留影響](#retention-period)。設定儲存設定時，請執行下列動作：
+  **熱方案保留** — 設定在刪除資料之前，將資料存放在熱方案中的保留期間，並根據儲存設定移至服務受管暖方案儲存或冷方案儲存。 AWS IoT SiteWise 會刪除保留期間結束前已存在的熱方案中的任何資料。如果您未設定保留期間，您的資料會無限期儲存在熱層中。
+  **暖層保留** - 設定保留期間，用於將資料從 AWS IoT SiteWise 儲存中刪除並移至客戶受管的冷層儲存之前，在暖層中存放多久。 會 AWS IoT SiteWise 刪除保留期間結束前存在的暖層中的任何資料。如果未設定保留期間，您的資料將無限期儲存在暖層中。

**注意**  
若要改善查詢效能，請使用暖層儲存設定熱層保留期。

## 熱層和暖層儲存中資料保留的影響
<a name="retention-period"></a>
+  當您減少熱層儲存的保留期間時，資料會從熱層永久移至暖層或冷層。當您減少暖層的保留期間時，資料會移至冷層，並從暖層永久刪除。
+  當您增加熱或暖層儲存的保留期間時，變更會影響 AWS IoT SiteWise 從 傳送至 的資料。 AWS IoT SiteWise 不會從暖或冷儲存擷取資料以填入熱層。例如，如果熱層儲存的保留期間最初設定為 30 天，然後增加到 60 天，則熱層儲存需要 30 天才能包含 60 天的資料。

**Topics**
+ [熱層和暖層儲存中資料保留的影響](#retention-period)
+ [設定暖層的儲存設定 （主控台）](#configure-storage-console-warm)
+ [設定暖層的儲存設定 (AWS CLI)](#configure-storage-cli-warm)
+ [設定冷層的儲存設定 （主控台）](#configure-storage-console)
+ [設定冷層的儲存設定 (AWS CLI)](#configure-storage-cli)

## 設定暖層的儲存設定 （主控台）
<a name="configure-storage-console-warm"></a>

下列程序說明如何在 AWS IoT SiteWise 主控台中設定儲存設定，將資料複寫至暖層。

**在主控台中設定儲存設定**

1. 導覽至 [AWS IoT SiteWise 主控台](https://console.aws.amazon.com/iotsitewise/)。

1. 在導覽窗格中的設定下****，選擇**儲存**。

1. 在右上角，選擇 **Edit (編輯)**。

1. 在**編輯儲存**頁面上，執行下列動作：

1. 對於**熱層設定**，請執行下列動作：
   + 如果您想要設定資料在刪除之前儲存在熱層中的保留期間，並移至服務受管暖層儲存，請選擇**啟用保留期間**。
   +  若要設定保留期間，請輸入整數並選擇單位。保留期間必須大於或等於 30 天。

   AWS IoT SiteWise 會刪除熱層中早於保留期間的任何資料。如果您未設定保留期間，您的資料會無限期儲存。

1. （建議） 針對**暖層設定**，請執行下列動作：
   + 若要選擇加入暖層儲存，請選取**我確認選擇加入暖層儲存**，以選擇加入暖層儲存。
   +  （選用） 若要設定保留期間，請輸入整數並選擇單位。保留期間必須大於或等於 365 天。

   AWS IoT SiteWise 會刪除暖層中比保留期間更早存在的資料。如果您未設定保留期間，您的資料會無限期儲存。
**注意**  
當您選擇加入暖層時，組態只會顯示一次。
若要設定熱層保留，您必須擁有暖層或冷層儲存。如需成本效益和歷史資料擷取， AWS IoT SiteWise 建議您將長期資料存放在暖層。
若要設定暖層保留，您必須擁有冷層儲存。

1. 選擇**儲存**以儲存儲存設定。

在**AWS IoT SiteWise 儲存**區段中，**暖層儲存**處於下列其中一種狀態：
+ **已啟用** – 如果您的資料在熱層保留期之前存在， AWS IoT SiteWise 會將資料移至暖層。」
+ **停用** – 停用暖層儲存。

## 設定暖層的儲存設定 (AWS CLI)
<a name="configure-storage-cli-warm"></a>

您可以使用 AWS CLI 和下列命令，設定儲存設定將資料移至暖層。

為了防止覆寫現有的組態，請執行下列命令來擷取目前的儲存組態資訊：

```
aws iotsitewise describe-storage-configuration
```

**Example 沒有現有冷層組態的回應**  

```
{
          "storageType": "SITEWISE_DEFAULT_STORAGE",
          "disassociatedDataStorage": "ENABLED",
          "configurationStatus": {
              "state": "ACTIVE"
          },
          "lastUpdateDate": "2021-10-14T15:53:35-07:00",
          "warmTier": "DISABLED"
}
```

**Example 使用現有冷層組態的 回應**  

```
{             
      "storageType": "MULTI_LAYER_STORAGE",
          "multiLayerStorage": {
            "customerManagedS3Storage": {
            "s3ResourceArn": "arn:aws:s3:::amzn-s3-demo-bucket/prefix/",
            "roleArn": "arn:aws:iam::aws-account-id:role/role-name"
            }
          },
      "disassociatedDataStorage": "ENABLED",
      "retentionPeriod": {
      "numberOfDays": retention-in-days
      },
       "configurationStatus": {
       "state": "ACTIVE"
      },
      "lastUpdateDate": "2023-10-25T15:59:46-07:00",
      "warmTier": "DISABLED"
}
```

### 使用 設定暖層的儲存設定 AWS CLI
<a name="configure-storage-cli-warm-tier"></a>

執行下列命令來設定儲存設定。`file-name` 將 取代為包含 AWS IoT SiteWise 儲存組態的檔案名稱。

```
aws iotsitewise put-storage-configuration --cli-input-json file://file-name.json
```

**Example AWS IoT SiteWise 具有熱層和暖層的 組態**  

```
{
             "storageType": "SITEWISE_DEFAULT_STORAGE",
             "disassociatedDataStorage": "ENABLED",
             "warmTier": "ENABLED",
             "retentionPeriod": {
                "numberOfDays": hot-tier-retention-in-days
              } 
              
}
```
`hot-tier-retention-in-days` 必須是大於或等於 30 天的整數。

**Example 回應**  

```
{
             "storageType": "SITEWISE_DEFAULT_STORAGE",
             "configurationStatus": {
             "state": "UPDATE_IN_PROGRESS"
             }
}
```

如果您已啟用冷層儲存，請參閱 [使用 AWS CLI 和現有的冷方案設定儲存體設定](#configure-storage-cli-existing-cold)。

### 使用 AWS CLI 和現有的冷方案設定儲存體設定
<a name="configure-storage-cli-existing-cold"></a>

**使用 AWS CLI 搭配現有的冷層儲存來設定儲存設定**
+ 執行下列命令來設定儲存設定。將 *file-name* 取代為包含 AWS IoT SiteWise 儲存組態的檔案名稱。

  ```
  aws iotsitewise put-storage-configuration --cli-input-json file://file-name.json
  ```  
**Example AWS IoT SiteWise 儲存體組態**  
  + 將 *amzn-s3-demo-bucket* 取代為您的 Amazon S3 儲存貯體名稱。
  + 將*字首*取代為您的 Amazon S3 字首。
  + 將 *aws-account-id* 取代為 AWS 您的帳戶 ID。
  + 將 *role-name* 取代為允許 AWS IoT SiteWise 將資料傳送至 Amazon S3 的 Amazon S3 存取角色名稱。
  + 以大於或等於 30 天的整數取代 *hot-tier-retention-in-days*day。
  + 以大於或等於 365 天的整數取代 *warm-tier-retention-in-days*day。
**注意**  
AWS IoT SiteWise 會刪除暖層中早於冷層保留期的任何資料。如果您未設定保留期間，您的資料會無限期儲存。

  ```
  {
        "storageType": "MULTI_LAYER_STORAGE",
          "multiLayerStorage": {
            "customerManagedS3Storage": {
                "s3ResourceArn": "arn:aws:s3:::amzn-s3-demo-bucket/prefix/",
                "roleArn": "arn:aws:iam::aws-account-id:role/role-name"
                }
            },
      "disassociatedDataStorage": "ENABLED",
      "retentionPeriod": {
        "numberOfDays": hot-tier-retention-in-days
      },
      "warmTier": "ENABLED",
      "warmTierRetentionPeriod": {
        "numberOfDays": warm-tier-retention-in-days
      }
  }
  ```  
**Example 回應**  

  ```
  {
        "storageType": "MULTI_LAYER_STORAGE",
        "configurationStatus": {
          "state": "UPDATE_IN_PROGRESS"
         }
  }
  ```

## 設定冷層的儲存設定 （主控台）
<a name="configure-storage-console"></a>

下列程序說明如何在 AWS IoT SiteWise 主控台中設定儲存設定，將資料複寫至冷層。

**在主控台中設定儲存設定**

1. 導覽至 [AWS IoT SiteWise 主控台](https://console.aws.amazon.com/iotsitewise/)。

1. 在導覽窗格中的設定下****，選擇**儲存**。

1. 在右上角，選擇 **Edit (編輯)**。

1. 在**編輯儲存**頁面上，執行下列動作：

   1. 針對**儲存設定**，選擇**啟用冷層儲存**。冷層儲存預設為停用。

   1. 針對 **S3 儲存貯體位置**，輸入現有 Amazon S3 儲存貯體的名稱和字首。
**注意**  
Amazon S3 使用 字首做為 Amazon S3 儲存貯體中的資料夾名稱。字首必須有 1-255 個字元，並以正斜線 (/) 結尾。 AWS IoT SiteWise 您的資料會儲存在此資料夾中。
如果您沒有 Amazon S3 儲存貯體，請選擇**檢視**，然後在 Amazon S3 主控台中建立一個。如需詳細資訊，請參閱《Amazon [ S3 使用者指南》中的建立您的第一個 S3 儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/GetStartedWithS3.html#creating-bucket)體。 *Amazon S3 *

   1. 對於 **S3 存取角色**，請執行下列其中一項操作：
      + 選擇**從 AWS 受管範本建立角色**， AWS 自動建立允許 將資料傳送至 Amazon S3 AWS IoT SiteWise 的 IAM 角色。
      + 選擇**使用現有角色**，然後從清單中選擇您建立的角色。
**注意**  
您必須對上一個步驟和 IAM 政策中使用的 S3 儲存貯體位置使用相同的 Amazon S3 儲存貯體名稱。 **S3 ** 
請確定您的角色具有下列範例所示的許可。  

**Example 許可政策：**    
****  

          ```
          {
                "Version":"2012-10-17",		 	 	 
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Action": [
                            "s3:PutObject",
                            "s3:GetObject",
                            "s3:DeleteObject",
                            "s3:GetBucketLocation",
                            "s3:ListBucket"
                        ],
                        "Resource": [
                            "arn:aws:s3:::amzn-s3-demo-bucket",
                            "arn:aws:s3:::amzn-s3-demo-bucket/*"
                        ]
                    }
                ]
            }
          ```
將 amzn-s3-demo-bucket 取代為您的 Amazon S3 儲存貯體名稱。
 如果 Amazon S3 儲存貯體使用客戶受管 KMS 金鑰加密，則 KMS 金鑰必須具有 `kms:Decrypt`和 `kms:GenerateDataKey`操作的 IAM 角色的存取政策。

   1. 若要設定熱層，請參閱 中的步驟 5[設定暖層的儲存設定 （主控台）](#configure-storage-console-warm)。

   1. （選用） 對於**AWS IoT Analytics 整合**，請執行下列動作。
**注意**  
終止支援通知： 將於 2025 年 12 月 15 AWS 日結束對 的支援 AWS IoT Analytics。2025 年 12 月 15 日之後，您將無法再存取 AWS IoT Analytics 主控台或 AWS IoT Analytics 資源。如需詳細資訊，請參閱[AWS IoT Analytics 終止支援](https://docs.aws.amazon.com/iotanalytics/latest/userguide/iotanalytics-end-of-support.html)。

      1. 如果您想要使用 AWS IoT Analytics 查詢資料，請選擇**已啟用 AWS IoT Analytics 的資料存放區**。

      1. AWS IoT SiteWise 會為您的資料存放區產生名稱，或者您可以輸入不同的名稱。

      AWS IoT SiteWise 會自動在 中建立資料存放區 AWS IoT Analytics ，以儲存您的資料。若要查詢資料，您可以使用 AWS IoT Analytics 來建立資料集。如需詳細資訊，請參閱*AWS IoT Analytics 《 使用者指南*》中的[使用 AWS IoT SiteWise 資料](https://docs.aws.amazon.com/iotanalytics/latest/userguide/dataset-itsw.html)。

   1. 選擇**儲存**。

在**AWS IoT SiteWise 儲存**區段中，**冷層儲存**可以是下列其中一個值：
+ **已啟用** – 將您的資料 AWS IoT SiteWise 複寫到指定的 Amazon S3 儲存貯體。
+ **啟用** – AWS IoT SiteWise 正在處理您的請求，以啟用冷層儲存。此程序可能需要幾分鐘的時間才能完成。
+ **Enable\$1Failed** – AWS IoT SiteWise 無法處理您的請求以啟用冷層儲存。如果您啟用 AWS IoT SiteWise 將日誌傳送至 Amazon CloudWatch Logs，您可以使用這些日誌來疑難排解問題。如需詳細資訊，請參閱[使用 Amazon CloudWatch Logs 監控](monitor-cloudwatch-logs.md)。
+ **已停用** – 冷層儲存已停用。

## 設定冷層的儲存設定 (AWS CLI)
<a name="configure-storage-cli"></a>

下列程序說明如何設定儲存設定，以使用 將資料複寫至冷層 AWS CLI。

**使用 設定儲存體設定 AWS CLI**

1. 若要將資料匯出至您帳戶中的 Amazon S3 儲存貯體，請執行下列命令來設定儲存體設定。將 *file-name* 取代為包含 AWS IoT SiteWise 儲存組態的檔案名稱。

   ```
   aws iotsitewise put-storage-configuration --cli-input-json file://file-name.json
   ```  
**Example AWS IoT SiteWise 儲存體組態**  
   + 將 *amzn-s3-demo-bucket* 取代為您的 Amazon S3 儲存貯體名稱。
   + 將*字首*取代為您的 Amazon S3 字首。
   + 將 *aws-account-id* 取代為 AWS 您的帳戶 ID。
   + 將 *role-name* 取代為允許 將資料 AWS IoT SiteWise 傳送至 Amazon S3 的 Amazon S3 存取角色名稱。
   + 將*retention-in-days*替換為整數大於或等於 30 天。

   ```
   {
         "storageType": "MULTI_LAYER_STORAGE",
         "multiLayerStorage": {
             "customerManagedS3Storage": {
                 "s3ResourceArn": "arn:aws:s3:::amzn-s3-demo-bucket/prefix/",
                 "roleArn": "arn:aws:iam::aws-account-id:role/role-name"
             }
         }, 
         "retentionPeriod": { 
             "numberOfDays": retention-in-days,
             "unlimited": false
         }
     }
   ```
**注意**  
您必須在 AWS IoT SiteWise 儲存組態和 IAM 政策中使用相同的 Amazon S3 儲存貯體名稱。
請確定您的角色具有下列範例所示的許可。  

**Example 許可政策：**    
****  

     ```
     {
           "Version":"2012-10-17",		 	 	 
           "Statement": [
               {
                   "Effect": "Allow",
                   "Action": [
                       "s3:PutObject",
                       "s3:GetObject",
                       "s3:DeleteObject",
                       "s3:GetBucketLocation",
                       "s3:ListBucket"
                   ],
                   "Resource": [
                       "arn:aws:s3:::amzn-s3-demo-bucket",
                       "arn:aws:s3:::amzn-s3-demo-bucket/*"
                   ]
               }
           ]
       }
     ```
將 amzn-s3-demo-bucket 取代為您的 Amazon S3 儲存貯體名稱。
 如果 Amazon S3 儲存貯體使用客戶受管 KMS 金鑰加密，則 KMS 金鑰必須具有 `kms:Decrypt`和 `kms:GenerateDataKey`操作的 IAM 角色的存取政策。  
**Example 回應**  

   ```
   {
       "storageType": "MULTI_LAYER_STORAGE",
       "retentionPeriod": {
           "numberOfDays": 100,
           "unlimited": false
       },
       "configurationStatus": {
           "state": "UPDATE_IN_PROGRESS"
       }
   }
   ```
**注意**  
 AWS IoT SiteWise 更新儲存組態可能需要幾分鐘的時間。

1. 若要擷取儲存組態資訊，請執行下列命令。

   ```
   aws iotsitewise describe-storage-configuration
   ```  
**Example 回應**  

   ```
   {
         "storageType": "MULTI_LAYER_STORAGE",
         "multiLayerStorage": {
             "customerManagedS3Storage": {
                 "s3ResourceArn": "arn:aws:s3:::amzn-s3-demo-bucket/torque/",
                 "roleArn": "arn:aws:iam::123456789012:role/SWAccessS3Role"
             }
         },
         "retentionPeriod": { 
             "numberOfDays": 100,
             "unlimited": false
         },
         "configurationStatus": {
             "state": "ACTIVE"
         },
         "lastUpdateDate": "2021-03-30T15:54:14-07:00"
     }
   ```

1. 若要停止將資料匯出至 Amazon S3 儲存貯體，請執行下列命令來設定儲存體設定。

   ```
   aws iotsitewise put-storage-configuration --storage-type SITEWISE_DEFAULT_STORAGE
   ```
**注意**  
根據預設，您的資料只會存放在 的熱層中 AWS IoT SiteWise。  
**Example 回應**  

   ```
   {
         "storageType": "SITEWISE_DEFAULT_STORAGE",
         "configurationStatus": {
             "state": "UPDATE_IN_PROGRESS"
         }
     }
   ```

1. 若要擷取儲存組態資訊，請執行下列命令。

   ```
   aws iotsitewise describe-storage-configuration
   ```  
**Example 回應**  

   ```
   {
         "storageType": "SITEWISE_DEFAULT_STORAGE",
         "configurationStatus": {
             "state": "ACTIVE"
         },
         "lastUpdateDate": "2021-03-30T15:57:14-07:00"
     }
   ```

### （選用） 建立 AWS IoT Analytics 資料存放區 (AWS CLI)
<a name="create-iotanalytics-data-store-cli"></a>

**注意**  
終止支援通知：在 2025 年 12 月 15 日， AWS 將終止對 的支援 AWS IoT Analytics。2025 年 12 月 15 日之後，您將無法再存取 AWS IoT Analytics 主控台或 AWS IoT Analytics 資源。如需詳細資訊，請參閱[AWS IoT Analytics 終止支援](https://docs.aws.amazon.com/iotanalytics/latest/userguide/iotanalytics-end-of-support.html)。

 AWS IoT Analytics 資料存放區是可擴展且可查詢的儲存庫，可接收和存放資料。您可以使用 AWS IoT SiteWise 主控台或 AWS IoT Analytics APIs來建立 AWS IoT Analytics 資料存放區，以儲存 AWS IoT SiteWise 您的資料。若要查詢資料，您可以使用 建立資料集 AWS IoT Analytics。如需詳細資訊，請參閱*AWS IoT Analytics 《 使用者指南*》中的[使用 AWS IoT SiteWise 資料](https://docs.aws.amazon.com/iotanalytics/latest/userguide/dataset-itsw.html)。

下列步驟使用 在其中 AWS CLI 建立資料存放區 AWS IoT Analytics。

若要建立資料存放區，請執行下列命令。將 *file-name* 取代為包含資料存放區組態的檔案名稱。

```
aws iotanalytics create-datastore --cli-input-json file://file-name.json
```

**注意**  
您必須指定現有 Amazon S3 儲存貯體的名稱。如果您沒有 Amazon S3 儲存貯體，請先建立一個。如需詳細資訊，請參閱《Amazon [ S3 使用者指南》中的建立您的第一個 S3 儲存貯](https://docs.aws.amazon.com/AmazonS3/latest/userguide/GetStartedWithS3.html#creating-bucket)體。 *Amazon S3 *
您必須在 AWS IoT SiteWise 儲存組態、IAM 政策和 AWS IoT Analytics 資料存放區組態中使用相同的 Amazon S3 儲存貯體名稱。

**Example AWS IoT Analytics 資料存放區組態**  
將 *data-store-name* 和 *amzn-s3-demo-bucket* 取代為您的 AWS IoT Analytics 資料存放區名稱和 Amazon S3 儲存貯體名稱。  

```
{
      "datastoreName": "data-store-name",
      "datastoreStorage": {
          "iotSiteWiseMultiLayerStorage": {
              "customerManagedS3Storage": {
                  "bucket": "amzn-s3-demo-bucket"
              }
          }
      },
      "retentionPeriod": {
          "numberOfDays": 90
      }
  }
```

**Example 回應**  

```
{
      "datastoreName": "datastore_IoTSiteWise_demo",
      "datastoreArn": "arn:aws:iotanalytics:us-west-2:123456789012:datastore/datastore_IoTSiteWise_demo",
      "retentionPeriod": {
          "numberOfDays": 90,
          "unlimited": false
      }
  }
```

# 對 的儲存設定進行故障診斷 AWS IoT SiteWise
<a name="troubleshoot-storage-configuration"></a>

使用以下資訊來疑難排解和解決儲存組態的問題。

**Topics**
+ [錯誤：儲存貯體不存在](#no-s3-bucket)
+ [錯誤：拒絕存取 Amazon S3 路徑](#iam-permissions)
+ [錯誤：無法擔任角色 ARN](#iam-trust-relationship)
+ [錯誤：無法存取跨區域 Amazon S3 儲存貯體](#cross-region-s3-bucket)

## 錯誤：儲存貯體不存在
<a name="no-s3-bucket"></a>

**Solution：** AWS IoT SiteWise 找不到您的 Amazon S3 儲存貯體。請務必輸入目前區域中現有 Amazon S3 儲存貯體的名稱。

## 錯誤：拒絕存取 Amazon S3 路徑
<a name="iam-permissions"></a>

**Solution：** AWS IoT SiteWise 無法存取您的 Amazon S3 儲存貯體。請執行下列操作：
+ 請務必使用您在 IAM 政策中指定的相同 Amazon S3 儲存貯體。
+ 請確定您的角色具有下列範例所示的許可。  
**Example 許可政策**  

------
#### [ JSON ]

****  

  ```
  {
        "Version":"2012-10-17",		 	 	 
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "s3:PutObject",
                    "s3:GetObject",
                    "s3:DeleteObject",
                    "s3:GetBucketLocation",
                    "s3:ListBucket"
                ],
                "Resource": [
                    "arn:aws:s3:::amzn-s3-demo-bucket",
                    "arn:aws:s3:::amzn-s3-demo-bucket/*"
                ]
            }
        ]
    }
  ```

------

  將 amzn-s3-demo-bucket 取代為您的 Amazon S3 儲存貯體名稱。

## 錯誤：無法擔任角色 ARN
<a name="iam-trust-relationship"></a>

**Solution：** AWS IoT SiteWise 無法代表您擔任 IAM 角色。請確定您的角色信任下列服務：`iotsitewise.amazonaws.com`。如需詳細資訊，請參閱 *IAM 使用者指南*中的[我無法擔任角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_roles.html#troubleshoot_roles_cant-assume-role)。

## 錯誤：無法存取跨區域 Amazon S3 儲存貯體
<a name="cross-region-s3-bucket"></a>

**解決方案：**您指定的 Amazon S3 儲存貯體位於不同的 AWS 區域。請確定您的 Amazon S3 儲存貯體和 AWS IoT SiteWise 資產位於相同的區域。

# 儲存在冷層中的資料檔案路徑和結構描述
<a name="file-path-and-schema"></a>

AWS IoT SiteWise 透過複寫時間序列，包括測量、指標、轉換和彙總，以及資產和資產模型定義，將您的資料存放在冷層中。以下說明傳送到冷層之資料的檔案路徑和結構描述。

**Topics**
+ [設備資料 （度量）](#measurements-file-path-and-schema)
+ [指標、轉換和彙總](#metrics-file-path-and-schema)
+ [資產中繼資料](#asset-metadata)
+ [資產階層中繼資料](#asset-hierarchy-metadata)
+ [儲存資料索引檔案](#storage-data-index)

## 設備資料 （度量）
<a name="measurements-file-path-and-schema"></a>

AWS IoT SiteWise 每六小時將設備資料 （測量） 匯出至冷方案一次。原始資料會以 [Apache AVRO ](https://avro.apache.org)(`.avro`) 格式儲存在冷層中。

### 檔案路徑
<a name="measurements-file-path"></a>

AWS IoT SiteWise 使用以下範本，將設備資料 （測量） 存放在冷層中。

```
{keyPrefix}/raw/startYear={startYear}/startMonth={startMonth}/startDay={startDay}/seriesBucket={seriesBucket}/raw_{timeseriesId}_{startTimestamp}_{quality}.avro
```

Amazon S3 中原始資料的每個檔案路徑都包含下列元件。

#### 檔案路徑
<a name="storage-paths-schemas-file-path"></a>


| 路徑元件 | Description | 
| --- | --- | 
|  `keyPrefix`  |  您在 AWS IoT SiteWise 儲存組態中指定的 Amazon S3 字首。Amazon S3 使用 字首做為儲存貯體中的資料夾名稱。  | 
|  `raw`  |  存放來自設備的時間序列資料的資料夾 （度量）。`raw` 資料夾會儲存在字首資料夾中。  | 
|  `seriesBucket`  |  介於 00 和 ff 之間的十六進位數字。此數字衍生自 `timeSeriesId`。此分割區用於在 AWS IoT SiteWise 寫入冷層時增加輸送量。當您使用 Amazon Athena 執行查詢時，您可以使用 分割區進行精細分割，以改善查詢效能。 `seriesBucket` 資產中繼資料`timeSeriesBucket`中的 和 是相同的數字。  | 
|  `startYear`  |  與時間序列資料相關聯的專屬開始時間年份。  | 
|  `startMonth`  |  與時間序列資料相關聯的專屬開始時間月份。  | 
|  `startDay`  |  與時間序列資料相關聯的專屬開始時間當月日期。  | 
|  `fileName`  |  檔案名稱使用底線 (\$1) 字元做為分隔符號來分隔下列項目： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/file-path-and-schema.html) 檔案會使用 [Snappy](https://github.com/google/snappy) 壓縮以 `.avro` 格式儲存。  | 

**Example 冷層中原始資料的檔案路徑**  
`keyPrefix/raw/startYear=2021/startMonth=1/startDay=2/seriesBucket=a2/raw_7020c8e2-e6db-40fa-9845-ed0dddd4c77d_95e63da7-d34e-43e1-bc6f-1b490154b07a_1609577700_GOOD.avro`

### 欄位
<a name="measurements-fields"></a>

匯出至冷層之原始資料的結構描述包含下列欄位。

 AWS IoT SiteWise 建議客戶在從冷層讀取原始資料的系統上實作結構描述演變的支援，因為未來可能會引入其他欄位。

 Null 資料表示為所有值欄位為 Null。不過，使用 AWS IoT SiteWise APIs 查詢時，客戶仍會收到正確的資料類型。

#### 欄位
<a name="measurements-fields-subsection"></a>


| 欄位名稱 | 支援的 類型 | 預設 類型 | Description | 
| --- | --- | --- | --- | 
|  `seriesId`  |  `string`  |  N/A  |  識別來自設備的時間序列資料的 ID （度量）。您可以使用此欄位在查詢中加入原始資料和資產中繼資料。  | 
|  `timeInSeconds`  |  `long`  |  N/A  |  時間戳記日期，以秒為單位，以 Unix epoch 格式顯示。分數奈秒資料由 提供`offsetInNanos`。  | 
|  `offsetInNanos`  |  `long`  |  N/A  |  與 的奈秒位移`timeInSeconds`。  | 
|  `quality`  |  `string`  |  N/A  |  時間序列值的品質。  | 
|  `doubleValue`  |  `double` 或 `null`  |  `null`  |  類型為雙的時間序列資料 （浮點數）。  | 
|  `stringValue`  |  `string` 或 `null`  |  `null`  |  類型字串的時間序列資料 （字元序列）。  | 
|  `integerValue`  |  `int` 或 `null`  |  `null`  |  整數類型的時間序列資料 （整數）。  | 
|  `booleanValue`  |  `boolean` 或 `null`  |  `null`  |  布林值類型的時間序列資料 (true 或 false)。  | 
|  `jsonValue`  |  `string` 或 `null`  |  `null`  |  JSON 類型的時間序列資料 （儲存為字串的複雜資料類型）。  | 
|  `recordVersion`  |  `long` 或 `null`  |  `null`  |  記錄的版本號碼。您可以使用版本號碼來選取最新的記錄。較新的記錄具有較大的版本編號。  | 

**Example 冷層中的原始資料**  

```
  {"seriesId":"e9687d2a-0dbe-4f65-9ed6-6f443cba41f7_95e63da7-d34e-43e1-bc6f-1b490154b07a","timeInSeconds":1625675887,"offsetInNanos":0,"quality":"GOOD","doubleValue":{"double":0.75},"stringValue":null,"integerValue":null,"booleanValue":null,"jsonValue":null,"recordVersion":null}
  {"seriesId":"e9687d2a-0dbe-4f65-9ed6-6f443cba41f7_95e63da7-d34e-43e1-bc6f-1b490154b07a","timeInSeconds":1625675889,"offsetInNanos":0,"quality":"GOOD","doubleValue":{"double":0.69},"stringValue":null,"integerValue":null,"booleanValue":null,"jsonValue":null,"recordVersion":null}
  {"seriesId":"e9687d2a-0dbe-4f65-9ed6-6f443cba41f7_95e63da7-d34e-43e1-bc6f-1b490154b07a","timeInSeconds":1625675890,"offsetInNanos":0,"quality":"GOOD","doubleValue":{"double":0.66},"stringValue":null,"integerValue":null,"booleanValue":null,"jsonValue":null,"recordVersion":null}
  {"seriesId":"e9687d2a-0dbe-4f65-9ed6-6f443cba41f7_95e63da7-d34e-43e1-bc6f-1b490154b07a","timeInSeconds":1625675891,"offsetInNanos":0,"quality":"GOOD","doubleValue":{"double":0.92},"stringValue":null,"integerValue":null,"booleanValue":null,"jsonValue":null,"recordVersion":null}
  {"seriesId":"e9687d2a-0dbe-4f65-9ed6-6f443cba41f7_95e63da7-d34e-43e1-bc6f-1b490154b07a","timeInSeconds":1625675892,"offsetInNanos":0,"quality":"GOOD","doubleValue":{"double":0.73},"stringValue":null,"integerValue":null,"booleanValue":null,"jsonValue":null,"recordVersion":null}
```

## 指標、轉換和彙總
<a name="metrics-file-path-and-schema"></a>

AWS IoT SiteWise 每六小時匯出一次指標、轉換和彙總至冷層。指標、轉換和彙總會以 [Apache AVRO ](https://avro.apache.org)(`.avro`) 格式儲存在冷層中。

### 檔案路徑
<a name="metrics-file-path"></a>

AWS IoT SiteWise 使用以下範本，將指標、轉換和彙總存放在冷層中。

```
{keyPrefix}/agg/startYear={startYear}/startMonth={startMonth}/startDay={startDay}/seriesBucket={seriesBucket}/agg_{timeseriesId}_{startTimestamp}_{quality}.avro
```

Amazon S3 中指標、轉換和彙總的每個檔案路徑都包含下列元件。

#### 檔案路徑
<a name="metrics-file-path-subsection"></a>


| 路徑元件 | Description | 
| --- | --- | 
|  `keyPrefix`  |  您在 AWS IoT SiteWise 儲存組態中指定的 Amazon S3 字首。Amazon S3 使用 字首做為儲存貯體中的資料夾名稱。  | 
|  `agg`  |  存放來自 指標的時間序列資料的資料夾。`agg` 資料夾會儲存在字首資料夾中。  | 
|  `seriesBucket`  |  介於 00 和 ff 之間的十六進位數字。此數字衍生自 `timeSeriesId`。此分割區用於在 AWS IoT SiteWise 寫入冷層時增加輸送量。當您使用 Amazon Athena 執行查詢時，您可以使用 分割區進行精細分割，以改善查詢效能。 `seriesBucket` 資產中繼資料`timeSeriesBucket`中的 和 是相同的數字。  | 
|  `startYear`  |  與時間序列資料相關聯的專屬開始時間年份。  | 
|  `startMonth`  |  與時間序列資料相關聯的專屬開始時間月份。  | 
|  `startDay`  |  與時間序列資料相關聯的專屬開始時間當月日期。  | 
|  `fileName`  |  檔案名稱使用底線 (\$1) 字元做為分隔符號來分隔下列項目： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/file-path-and-schema.html) 檔案會使用 [Snappy](https://github.com/google/snappy) 壓縮以 `.avro` 格式儲存。  | 

**Example 冷層中指標的檔案路徑**  
`keyPrefix/agg/startYear=2021/startMonth=1/startDay=2/seriesBucket=a2/agg_7020c8e2-e6db-40fa-9845-ed0dddd4c77d_95e63da7-d34e-43e1-bc6f-1b490154b07a_1609577700_GOOD.avro`

### 欄位
<a name="metrics-fields"></a>

匯出至冷層的指標、轉換和彙總結構描述包含下列欄位。

#### 欄位
<a name="metrics-fields-subsection"></a>


| 欄位名稱 | 支援的 類型 | 預設 類型 | Description | 
| --- | --- | --- | --- | 
|  `seriesId`  |  `string`  |  N/A  |  識別來自設備、指標或轉換的時間序列資料的 ID。您可以使用此欄位在查詢中加入原始資料和資產中繼資料。  | 
|  `timeInSeconds`  |  `long`  |  N/A  |  時間戳記日期，以秒為單位，以 Unix epoch 格式顯示。分數奈秒資料由 提供`offsetInNanos`。  | 
|  `offsetInNanos`  |  `long`  |  N/A  |  與 的奈秒位移`timeInSeconds`。  | 
|  `quality`  |  `string`  |  N/A  |  篩選資產資料的品質。  | 
|  `resolution`  |  `string`  |  N/A  |  要彙總資料的時間間隔。  | 
|  `count`  |  `double` 或 `null`  |  `null`  |  目前時間間隔內指定變數的資料點總數。  | 
|  `average`  |  `double` 或 `null`  |  `null`  |  目前時間間隔內指定變數值的平均值。  | 
|  `min`  |  `double` 或 `null`  |  `null`  |  在目前時間間隔內指定變數值的最小值。  | 
|  `max`  |  `boolean` 或 `null`  |  `null`  |  在目前時間間隔內指定變數值的最大值。  | 
|  `sum`  |  `string` 或 `null`  |  `null`  |  指定變數在目前時間間隔內的值總和。  | 
|  `recordVersion`  |  `long` 或 `null`  |  `null`  |  記錄的版本號碼。您可以使用版本號碼來選取最新的記錄。較新的記錄具有較大的版本編號。  | 

**Example 冷層中的指標資料**  

```
{"seriesId":"f74c2828-5317-4df3-ba16-6d41b5bcb531","timeInSeconds":1637334060,"offsetInNanos":0,"quality":"GOOD","resolution":"PT1M","count":31.0,"average":{"double":16.0},"min":{"double":1.0},"max":{"double":31.0},"sum":{"double":496.0},"recordVersion":null}
  {"seriesId":"f74c2828-5317-4df3-ba16-6d41b5bcb531","timeInSeconds":1637334120,"offsetInNanos":0,"quality":"GOOD","resolution":"PT1M","count":29.0,"average":{"double":46.0},"min":{"double":32.0},"max":{"double":60.0},"sum":{"double":1334.0},"recordVersion":null}
  {"seriesId":"f74c2828-5317-4df3-ba16-6d41b5bcb531","timeInSeconds":1637334540,"offsetInNanos":0,"quality":"GOOD","resolution":"PT1M","count":31.0,"average":{"double":16.0},"min":{"double":1.0},"max":{"double":31.0},"sum":{"double":496.0},"recordVersion":null}
  {"seriesId":"f74c2828-5317-4df3-ba16-6d41b5bcb531","timeInSeconds":1637334600,"offsetInNanos":0,"quality":"GOOD","resolution":"PT1M","count":29.0,"average":{"double":46.0},"min":{"double":32.0},"max":{"double":60.0},"sum":{"double":1334.0},"recordVersion":null}
  {"seriesId":"f74c2828-5317-4df3-ba16-6d41b5bcb531","timeInSeconds":1637335020,"offsetInNanos":0,"quality":"GOOD","resolution":"PT1M","count":31.0,"average":{"double":16.0},"min":{"double":1.0},"max":{"double":31.0},"sum":{"double":496.0},"recordVersion":null}
```

## 資產中繼資料
<a name="asset-metadata"></a>

當您第一次啟用 AWS IoT SiteWise 將資料匯出至冷層時，資產中繼資料會匯出至冷層。在初始組態之後，只有在您變更資產模型定義或資產定義時， 才會將資產中繼資料 AWS IoT SiteWise 匯出至層。資產中繼資料會以換行分隔 JSON (`.ndjson`) 格式儲存在冷層中。

### 檔案路徑
<a name="asset-metadata-file-path"></a>

AWS IoT SiteWise 使用以下範本，將資產中繼資料存放在冷層中。

```
{keyPrefix}/asset_metadata/asset_{assetId}.ndjson
```

冷層中資產中繼資料的每個檔案路徑都包含下列元件。

#### 檔案路徑
<a name="asset-metadata-file-path-subsection"></a>


| 路徑元件 | Description | 
| --- | --- | 
|  `keyPrefix`  |  您在 儲存組態中指定的 Amazon S3 AWS IoT SiteWise字首。Amazon S3 使用 字首做為儲存貯體中的資料夾名稱。  | 
|  `asset_metadata`  |  存放資產中繼資料的資料夾。`asset_metadata` 資料夾會儲存在字首資料夾中。  | 
|  `fileName`  |  檔案名稱使用底線 (\$1) 字元做為分隔符號來分隔下列項目： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/file-path-and-schema.html) 檔案會以 `.ndjson` 格式儲存。  | 

**Example 較冷層中資產中繼資料的檔案路徑**  
`keyPrefix/asset_metadata/asset_35901915-d476-4dca-8637-d9ed4df939ed.ndjson`

### 欄位
<a name="asset-metadata-fields"></a>

匯出至冷層的資產中繼資料結構描述包含下列欄位。

#### 欄位
<a name="asset-metadata-fields-subsection"></a>


| 欄位名稱 | Description | 
| --- | --- | 
|  `assetId`  |   資產的 ID。  | 
|  `assetName`  |  資產的名稱。  | 
|  `assetExternalId`  |  資產的外部 ID。  | 
|  `assetModelId`  |  用來建立此資產的資產模型 ID。  | 
|  `assetModelName`  |  資產模型的名稱。  | 
|  `assetModelExternalId`  |  資產模型的外部 ID。  | 
|  `assetPropertyId`  |  資產屬性的 ID。  | 
|  `assetPropertyName`  |  資產屬性的名稱。  | 
|  `assetPropertyExternalId`  |  資產屬性的外部 ID。  | 
|  `assetPropertyDataType`  |  資產屬性的資料類型。  | 
|  `assetPropertyUnit`  |  資產屬性的單位 （例如 `Newtons`和 `RPM`)。  | 
|  `assetPropertyAlias`  |  識別資產屬性的別名，例如 OPC UA 伺服器資料串流路徑 （例如 `/company/windfarm/3/turbine/7/temperature`)。  | 
|  `timeSeriesId`  |  識別來自設備、指標或轉換的時間序列資料的 ID。您可以使用此欄位在查詢中加入原始資料和資產中繼資料。  | 
|  `timeSeriesBucket`  |  介於 00 和 ff 之間的十六進位數字。此數字衍生自 `timeSeriesId`。此分割區用於在 AWS IoT SiteWise 寫入冷層時增加輸送量。當您使用 Amazon Athena 執行查詢時，您可以使用分割區進行精細分割，以改善查詢效能。 `timeSeriesBucket` 原始資料的檔案路徑`seriesBucket`中的 和 是相同的數字。  | 
|  `assetCompositeModelId`  |  複合模型的 ID。  | 
|  `assetCompositeModelExternalId`  |  複合模型的外部 ID。  | 
|  `assetCompositeModelDescription`  |  複合模型的描述。  | 
|  `assetCompositeModelName`  |  複合模型的名稱。  | 
|  `assetCompositeModelType`  |  複合模型的類型。對於警示複合模型，類型是 `AWS/ALARM`。  | 
|  `assetCreationDate`  |  資產建立的日期，以 Unix epoch 時間表示。  | 
|  `assetLastUpdateDate`  |  資產上次更新的日期，以 Unix epoch 時間表示。  | 
|  `assetStatusErrorCode`  |  錯誤代碼。  | 
|  `assetStatusErrorMessage`  |  錯誤訊息。  | 
|  `assetStatusState`  |  資產的目前狀態。  | 

**Example 冷層中的資產中繼資料**  

```
  {"assetId":"7020c8e2-e6db-40fa-9845-ed0dddd4c77d","assetExternalId":null,"assetName":"Wind Turbine Asset 2","assetModelId":"ec1d924f-f07d-444f-b072-e2994c165d35","assetModelExternalId":null,"assetModelName":"Wind Turbine Asset Model","assetPropertyId":"95e63da7-d34e-43e1-bc6f-1b490154b07a","assetPropertyExternalId":null,"assetPropertyName":"Temperature","assetPropertyDataType":"DOUBLE","assetPropertyUnit":"Celsius","assetPropertyAlias":"USA/Washington/Seattle/WT2/temp","timeSeriesId":"7020c8e2-e6db-40fa-9845-ed0dddd4c77d_95e63da7-d34e-43e1-bc6f-1b490154b07a","timeSeriesBucket":"f6","assetArn":null,"assetCompositeModelDescription":null,"assetCompositeModelName":null,"assetCompositeModelType":null,"assetCompositeModelId":null,"assetCompositeModelExternalId":null,"assetCreationDate":1619466323,"assetLastUpdateDate":1623859856,"assetStatusErrorCode":null,"assetStatusErrorMessage":null,"assetStatusState":"ACTIVE"}
  {"assetId":"7020c8e2-e6db-40fa-9845-ed0dddd4c77d","assetExternalId":null,"assetName":"Wind Turbine Asset 2","assetModelId":"ec1d924f-f07d-444f-b072-e2994c165d35","assetModelExternalId":null,"assetModelName":"Wind Turbine Asset Model","assetPropertyId":"c706d54d-4c11-42dc-9a01-63662fc697b4","assetPropertyExternalId":null,"assetPropertyName":"Pressure","assetPropertyDataType":"DOUBLE","assetPropertyUnit":"KiloPascal","assetPropertyAlias":"USA/Washington/Seattle/WT2/pressure","timeSeriesId":"7020c8e2-e6db-40fa-9845-ed0dddd4c77d_c706d54d-4c11-42dc-9a01-63662fc697b4","timeSeriesBucket":"1e","assetArn":null,"assetCompositeModelDescription":null,"assetCompositeModelName":null,"assetCompositeModelType":null,"assetCompositeModelId":null,"assetCompositeModelExternalId":null,"assetCreationDate":1619466323,"assetLastUpdateDate":1623859856,"assetStatusErrorCode":null,"assetStatusErrorMessage":null,"assetStatusState":"ACTIVE"}
  {"assetId":"7020c8e2-e6db-40fa-9845-ed0dddd4c77d","assetExternalId":null,"assetName":"Wind Turbine Asset 2","assetModelId":"ec1d924f-f07d-444f-b072-e2994c165d35","assetModelExternalId":null,"assetModelName":"Wind Turbine Asset Model","assetPropertyId":"8cf1162f-dead-4fbe-b468-c8e24cde9f50","assetPropertyExternalId":null,"assetPropertyName":"Max Temperature","assetPropertyDataType":"DOUBLE","assetPropertyUnit":null,"assetPropertyAlias":null,"timeSeriesId":"7020c8e2-e6db-40fa-9845-ed0dddd4c77d_8cf1162f-dead-4fbe-b468-c8e24cde9f50","timeSeriesBucket":"d7","assetArn":null,"assetCompositeModelDescription":null,"assetCompositeModelName":null,"assetCompositeModelType":null,"assetCompositeModelId":null,"assetCompositeModelExternalId":null,"assetCreationDate":1619466323,"assetLastUpdateDate":1623859856,"assetStatusErrorCode":null,"assetStatusErrorMessage":null,"assetStatusState":"ACTIVE"}
  {"assetId":"3a5f2a22-3b37-4332-9c1c-404ea1d73fab","assetExternalId":null,"assetName":"BatchAssetDouble1","assetModelId":"814bdfd8-24db-4a33-8d9b-ebc75e75e827","assetModelExternalId":null,"assetModelName":"FlashTestAssetModelDouble","assetPropertyId":"6b7e1532-175b-4c02-b410-ab401a9176ed","assetPropertyExternalId":null,"assetPropertyName":"measurementProperty","assetPropertyDataType":"DOUBLE","assetPropertyUnit":"u","assetPropertyAlias":null,"timeSeriesId":"ab19f4fa-7e7b-4247-ae89-ff316f5ff8aa","timeSeriesBucket":"af","assetArn":null,"assetCompositeModelDescription":null,"assetCompositeModelName":null,"assetCompositeModelType":null,"assetCompositeModelId":null,"assetCompositeModelExternalId":null,"assetCreationDate":1646960106,"assetLastUpdateDate":1646960106,"assetStatusErrorCode":null,"assetStatusErrorMessage":null,"assetStatusState":"ACTIVE"}
```

## 資產階層中繼資料
<a name="asset-hierarchy-metadata"></a>

當您第一次啟用 AWS IoT SiteWise 將資料儲存在冷層時，資產階層中繼資料會匯出至冷層。在初始組態之後，只有在您變更資產模型或資產定義時， 才會將資產階層中繼資料 AWS IoT SiteWise 匯出至冷層。資產階層中繼資料會以換行分隔 JSON (`.ndjson`) 格式儲存在冷層中。

透過呼叫 [DescribeAsset](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_DescribeAsset.html) API 來擷取階層、目標資產或來源資產的外部識別符。

### 檔案路徑
<a name="asset-hierarchy-metadata-file-path"></a>

AWS IoT SiteWise 使用以下範本，將資產階層中繼資料儲存在冷層中。

```
{keyPrefix}/asset_hierarchy_metadata/{parentAssetId}_{hierarchyId}.ndjson
```

冷層中資產階層中繼資料的每個檔案路徑都包含下列元件。

#### 檔案路徑
<a name="asset-hierarchy-metadata-file-path-subsection"></a>


| 路徑元件 | Description | 
| --- | --- | 
|  `keyPrefix`  |  您在 AWS IoT SiteWise 儲存組態中指定的 Amazon S3 字首。Amazon S3 使用 字首做為儲存貯體中的資料夾名稱。  | 
|  `asset_hierarchy_metadata`  |  存放資產階層中繼資料的資料夾。`asset_hierarchy_metadata` 資料夾會儲存在字首資料夾中。  | 
|  `fileName`  |  檔案名稱使用底線 (\$1) 字元做為分隔符號來分隔下列項目： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/iot-sitewise/latest/userguide/file-path-and-schema.html) 檔案會以 `.ndjson` 格式儲存。  | 

**Example 冷層中資產階層中繼資料的檔案路徑**  
`keyPrefix/asset_hierarchy_metadata/35901915-d476-4dca-8637-d9ed4df939ed_c5b3ced8-589a-48c7-9998-cdccfc9747a0.ndjson`

### 欄位
<a name="asset-hierarchy-metadata-fields"></a>

匯出至冷層的資產階層中繼資料結構描述包含下列欄位。

#### 欄位
<a name="asset-hierarchy-metadata-fields-subsection"></a>


| 欄位名稱 | Description | 
| --- | --- | 
|  `sourceAssetId`  |  此資產關係中來源資產的 ID。  | 
|  `targetAssetId`  |  此資產關係中目標資產的 ID。  | 
|  `hierarchyId`  |  階層的 ID。  | 
|  `associationType`  |  此資產關係的關聯類型。 值必須為 `CHILD`。目標資產是來源資產的子資產。  | 

**Example 冷層中的資產階層中繼資料**  

```
{"sourceAssetId":"80388e72-2284-44fb-9c89-bfbaf0dfedd2","targetAssetId":"2b866c25-0c74-4750-bdf5-b73683c8a2a2","hierarchyId":"bbed9f59-0412-4585-a61d-6044db526aee","associationType":"CHILD"}
  {"sourceAssetId":"80388e72-2284-44fb-9c89-bfbaf0dfedd2","targetAssetId":"6b51246e-984d-460d-bc0b-470ea47d1e31","hierarchyId":"bbed9f59-0412-4585-a61d-6044db526aee","associationType":"CHILD"}
```

**在冷方案中檢視您的資料**

1. 導覽至 [Amazon S3 主控台](https://console.aws.amazon.com/s3/)。

1. 在導覽窗格中，選擇**儲存貯體**，然後選擇您的 Amazon S3 儲存貯體。

1. 導覽至包含原始資料、資產中繼資料或資產階層中繼資料的資料夾。

1. 選取檔案，然後從**動作**中選擇**下載**。

## 儲存資料索引檔案
<a name="storage-data-index"></a>

AWS IoT SiteWise 使用這些檔案來最佳化資料查詢效能。它們會出現在 Amazon S3 儲存貯體中，但您不需要使用它們。

### 檔案路徑
<a name="storage-data-index-file-path"></a>

AWS IoT SiteWise 使用以下範本將資料索引檔案存放在冷層。

```
keyPrefix/index/series=timeseriesId/startYear=startYear/startMonth=startMonth/startDay=startDay/index_timeseriesId_startTimestamp_quality
```

**Example 資料儲存索引檔案的檔案路徑**  
`keyPrefix/index/series=7020c8e2-e6db-40fa-9845-ed0dddd4c77d_95e63da7-d34e-43e1-bc6f-1b490154b07a/startYear=2022/startMonth=02/startDay=03/index_7020c8e2-e6db-40fa-9845-ed0dddd4c77d_95e63da7-d34e-43e1-bc6f-1b490154b07a_1643846400_GOOD`