設定及管理 Storage Intelligence

Storage Intelligence 可深入分析儲存空間用量模式,協助您管理資料和基礎架構。這些洞察資料可協助您找出可進行成本最佳化、提升效能,以及改善安全性或法規遵循的領域。這項服務也支援重新定位及處理資料。本指南說明如何為資源設定、查看、更新及停用 Storage Intelligence 功能。

必要的角色

如要取得設定及管理 Storage Intelligence 所需的權限,請要求管理員授予您專案、資料夾或機構的儲存空間管理員 (roles/storage.admin) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

這個預先定義的角色具備設定及管理 Storage Intelligence 所需的權限。如要查看確切的必要權限,請展開「Required permissions」(必要權限) 部分:

所需權限

您必須具備下列權限,才能設定及管理 Storage Intelligence:

  • 設定 Storage Intelligence: storage.intelligenceConfigs.update
  • 查看 Storage Intelligence 設定: storage.intelligenceConfigs.get
  • 更新 Storage Intelligence 設定: storage.intelligenceConfigs.update
  • 停用 Storage Intelligence: storage.intelligenceConfigs.update

您或許還可透過自訂角色或其他預先定義的角色取得這些權限。

設定 Storage Intelligence

控制台

  1. 前往 Google Cloud 控制台的 Storage Intelligence「Configuration」(設定) 頁面。

    前往「設定」

  2. 按一下「啟用 Storage Intelligence」。

  3. 在「設定 Storage Intelligence」對話方塊中,選取要設定 Storage Intelligence 的資源。

  4. 按一下「繼續」。

  5. 選用步驟:如要在 Storage Intelligence 設定中納入或排除特定 bucket,請按照下列步驟操作:

    1. 如要選取特定位置中的 bucket,請使用篩選器類型選單。如要納入或排除 bucket,請從「位置」選單中選取位置。詳情請參閱「依位置篩選」。

    2. 如要依名稱選取 Cloud Storage bucket,請使用「篩選類型」選單。如要加入或排除 bucket,請指定 bucket 名稱的規則運算式,然後按一下「Add regular expression」(新增規則運算式)。詳情請參閱「依 bucket 名稱篩選」。

  6. 按一下「啟用這項設定」。

指令列

  1. 在 Google Cloud 控制台啟用 Cloud Shell。

    啟用 Cloud Shell

    Google Cloud 控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已設定適用於您目前專案的值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 如要設定 Storage Intelligence,請使用 gcloud storage intelligence-configs enable 指令,並搭配下列其中一個旗標:

    • --project:為專案設定 Storage Intelligence。這個值是專案 ID。例如:my-project。

    • --sub-folder:為資料夾設定 Storage Intelligence。值為資料夾 ID。例如:1234567890。

    • --organization:為機構設定 Storage Intelligence。這個值是組織 ID。例如:9876546738。

      舉例來說,下列指令會為名為 my-project 的專案設定 Storage Intelligence:

      gcloud storage intelligence-configs enable --project=PROJECT_ID

      其中的 PROJECT_ID 為專案 ID。

    如要在 Storage Intelligence 設定中納入或排除特定 bucket,請使用任一下列標記:

    • --exclude-bucket-regexes:要從 Storage Intelligence 設定中排除的 bucket ID 規則運算式清單。
    • --include-bucket-regexes:要納入 Storage Intelligence 設定的 bucket ID 正則運算式清單。

    舉例來說,如要排除名稱中含有「colddata」的所有 bucket,請使用下列指令:

    gcloud storage intelligence-configs enable --organization=54343 --exclude-bucket-regexes=colddata.*

    舉例來說,如要排除名為 colddata 的 bucket,請使用下列指令:

    gcloud storage intelligence-configs enable --organization=54343 --exclude-bucket-regexes=colddata

    舉例來說,如要排除名為「colour」或「color」的 bucket,請使用下列指令:

    gcloud storage intelligence-configs enable --organization=my-org --exclude-bucket-regexes=colou?r

    如要根據 bucket 的位置納入或排除 bucket,請在 Storage Intelligence 設定中使用下列任一標記:

    • --exclude-locations:要從 Storage Intelligence 設定中排除的位置清單。
    • --include-locations:要納入 Storage Intelligence 設定的位置清單。

    例如:

    gcloud storage intelligence-configs enable --sub-folder=123456 --include-locations=us-east1,us-west1

REST API

JSON API

  1. 安裝並初始化 gcloud CLI,以便為 Authorization 標頭產生存取權杖。

  2. 建立 JSON 檔案,並加入下列詳細資料:

    1. name:Storage Intelligence 設定的名稱。請使用下列任一格式:
      • 專案:projects/PROJECT_ID/locations/global/intelligenceConfig
      • 資料夾:folders/FOLDER_ID/locations/global/intelligenceConfig
      • 機構:organizations/ORGANIZATION_ID/locations/global/intelligenceConfig

      其中:

      • PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project
      • FOLDER_ID 是 Google Cloud 資料夾 ID。資料夾 ID 為數字,例如 123456789012
      • ORGANIZATION_ID 是 Google Cloud 組織 ID。組織 ID 為數字,例如 123456789012
    2. 設定 editionConfig 欄位。詳情請參閱「版本設定」。
    3. 選用:設定 filter 物件。您可以根據 Cloud Storage 位置和bucket ID 規則運算式,加入或排除 bucket。
        {
          "name":"projects/PROJECT_ID/locations/global/intelligenceConfig",
          "editionConfig":"EDITION_CONFIGURATION",
          "filter":{
            "includedCloudStorageBuckets":{
                "bucketIdRegexes":[
                  "INCLUDED_BUCKET_ID_REGEX",
                    ...]
            },
            "excludedCloudStorageBuckets":{
                "bucketIdRegexes":[
                  "EXCLUDED_BUCKET_ID_REGEX",
                    ...]
            },
            "includedCloudStorageLocations":{
                "locations":[
                  "INCLUDED_BUCKET_LOCATION",
                    ...]
            },
            "excludedCloudStorageLocations":{
                "locations":[
                  "EXCLUDED_BUCKET_LOCATION",
                    ...]
            }
          }
        }
      

    其中:

    • PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project。
    • EDITION_CONFIGURATION 是 Storage Intelligence 版本設定。
    • 選用:INCLUDED_BUCKET_ID_REGEX 是規則運算式,用來指定要納入哪些 bucket ID。您可以指定一或多個規則運算式做為清單。
    • 選用:EXCLUDED_BUCKET_ID_REGEX 是規則運算式,用來指定要排除的 bucket ID。您可以指定一或多個規則運算式做為清單。
    • 選用:INCLUDED_BUCKET_LOCATION 是您要在 Storage Intelligence 設定中納入 bucket 的位置。您可以指定一或多個位置做為清單。
    • 選用:EXCLUDED_BUCKET_LOCATION 是要從 Storage Intelligence 設定中排除 bucket 的位置。您可以指定一或多個位置做為清單。
  3. 以下各節說明如何使用 REST API,為專案、資料夾或機構設定 Storage Intelligence。您也可以使用 REST API 設定 Storage Intelligence 30 天入門試用方案。使用下列任一方法,設定 Storage Intelligence 或 Storage Intelligence 30 天入門試用方案。

    為專案設定 Storage Intelligence

    使用 cURL 呼叫 JSON API,為專案設定 Storage Intelligence。

      curl -X POST \
        --data-binary @JSON_FILE_NAME \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -H "Content-Type: application/json" \
        "https://storage.googleapis.com/v2/projects/PROJECT_ID/locations/global/intelligenceConfig?updateMask=UPDATE_MASK"
    

    其中:

    • PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 由英數字元組成,例如 my-project
    • UPDATE_MASK 是以半形逗號分隔的欄位名稱清單,列出這項要求更新的欄位。這些欄位採用 FieldMask 格式,屬於 IntelligenceConfig 資源的一部分。

    為資料夾設定 Storage Intelligence

    使用 cURL 呼叫 JSON API,為資料夾設定 Storage Intelligence。

      curl -X POST \
        --data-binary @JSON_FILE_NAME \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -H "Content-Type: application/json" \
        "https://storage.googleapis.com/v2/folders/FOLDER_ID/locations/global/intelligenceConfig?updateMask=UPDATE_MASK"
    

    其中:

    • FOLDER_ID 是 Google Cloud 資料夾 ID。資料夾 ID 為數字,例如 123456789012
    • UPDATE_MASK 是以半形逗號分隔的欄位名稱清單,列出這項要求更新的欄位。這些欄位採用 FieldMask 格式,屬於 IntelligenceConfig 資源的一部分。

    為機構設定 Storage Intelligence

    使用 cURL 呼叫 JSON API,為機構設定 Storage Intelligence。

    curl -X POST \
      --data-binary @JSON_FILE_NAME \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      -H "Content-Type: application/json" \
      "https://storage.googleapis.com/v2/organizations/ORGANIZATION_ID/locations/global/intelligenceConfig?updateMask=UPDATE_MASK"
    

    其中:

    • ORGANIZATION_ID 是 Google Cloud 組織 ID。組織 ID 為數字,例如 79293024087
    • UPDATE_MASK 是以半形逗號分隔的欄位名稱清單,列出這項要求更新的欄位。這些欄位採用 FieldMask 格式,屬於 IntelligenceConfig 資源。

查看 Storage Intelligence 設定

控制台

  1. 前往 Google Cloud 控制台的「Storage Intelligence Configuration」(儲存空間智慧設定) 頁面。

    前往「設定」

  2. 選取頁面頂端的專案挑選器。

  3. 在「Select a resource」(選取資源) 對話方塊中,選取要查看 Storage Intelligence 設定的資源。

如果資源已設為使用 Storage Intelligence,「Status」(狀態) 欄位會顯示 Enabled。如果資源未設定 Storage Intelligence,系統會顯示「設定 Storage Intelligence」按鈕。

指令列

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    Google Cloud 控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已設定適用於您目前專案的值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 如要查看資源的 Storage Intelligence 設定,請使用 gcloud storage intelligence-configs describe 指令,並搭配下列其中一個標記:

    • --project:查看專案的 Storage Intelligence 設定。這個值是專案 ID。例如:my-project。

    • --sub-folder:查看資料夾的 Storage Intelligence 設定。值為資料夾 ID。例如:1234567890。

    • --organization:查看機構的 Storage Intelligence 設定。這個值是組織 ID。例如:9876546738。

      舉例來說,下列指令會查看名為 my-project 的專案的 Storage Intelligence 設定:

      gcloud storage intelligence-configs describe --project=PROJECT_ID

      其中 PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project。

REST API

JSON API

  1. 安裝並初始化 gcloud CLI,以便為 Authorization 標頭產生存取權杖。

  2. 如要瞭解如何查看資源的 Storage Intelligence 設定,請參閱下列章節。

    查看專案的 Storage Intelligence 設定

    使用 cURL 呼叫 JSON API,查看專案的 Storage Intelligence 設定。

      curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        "https://storage.googleapis.com/v2/projects/PROJECT_ID/locations/global/intelligenceConfig"
    

    其中:

    PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project。

    查看資料夾的 Storage Intelligence 設定

    使用 cURL 呼叫 JSON API,查看資料夾的 Storage Intelligence 設定。

      curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        "https://storage.googleapis.com/v2/folders/FOLDER_ID/locations/global/intelligenceConfig"
    

    其中:

    FOLDER_ID 是 Google Cloud 資料夾 ID。資料夾 ID 為數字,例如 123456789012。

    查看機構的 Storage Intelligence 設定

    使用 cURL 呼叫 JSON API,查看機構的 Storage Intelligence 設定。

      curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        "https://storage.googleapis.com/v2/organizations/ORGANIZATION_ID/locations/global/intelligenceConfig"
    

    其中:

    ORGANIZATION_ID 是 Google Cloud 組織 ID。組織 ID 為數字,例如 79293024087。

更新 Storage Intelligence 設定

控制台

  1. 前往 Google Cloud 控制台的「Storage Intelligence Configuration」(儲存空間智慧設定) 頁面。

    前往「設定」

  2. 選取頁面頂端的專案挑選器。

  3. 在「Select a resource」(選取資源) 對話方塊中,選取要更新 Storage Intelligence 設定的資源。

  4. 在「Overview」(總覽) 部分,視需要修改任何可編輯的設定選項。舉例來說,您可以為資源停用 Storage Intelligence,或將版本設定變更為 Inherit from parent,也可以變更儲存空間篩選器。

指令列

  1. 在 Google Cloud 控制台中啟用 Cloud Shell。

    啟用 Cloud Shell

    Google Cloud 控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已設定適用於您目前專案的值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 如要更新資源的 Storage Intelligence 設定,請使用 gcloud storage intelligence-configs update 指令,並搭配下列其中一個旗標:

    • --project:更新專案的 Storage Intelligence 設定。這個值是專案 ID。例如:my-project。

    • --sub-folder:更新資料夾的 Storage Intelligence 設定。值為資料夾 ID。例如:1234567890。

    • --organization:更新機構的 Storage Intelligence 設定。值為組織 ID。例如:9876546738。

      舉例來說,下列指令會更新名為 my-project 的專案的 Storage Intelligence 設定:

      gcloud storage intelligence-configs update --project=PROJECT_ID

      其中 PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 由英數字元組成,例如 my-project。

REST API

JSON API

  1. 安裝並初始化 gcloud CLI,以便為 Authorization 標頭產生存取權杖。

  2. 建立 JSON 檔案,並加入下列詳細資料:

    1. name:Storage Intelligence 設定的名稱。請使用下列任一格式:
      • 專案:projects/PROJECT_ID/locations/global/intelligenceConfig
      • 資料夾:folders/FOLDER_ID/locations/global/intelligenceConfig
      • 機構:organizations/ORGANIZATION_ID/locations/global/intelligenceConfig

      其中:

      • PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 由英數字元組成,例如 my-project
      • FOLDER_ID 是 Google Cloud 資料夾 ID。資料夾 ID 為數字,例如 123456789012
      • ORGANIZATION_ID 是 Google Cloud 組織 ID。組織 ID 為數字,例如 123456789012
    2. 設定 editionConfig 欄位。詳情請參閱「版本設定」。
    3. 選用:設定 filter 物件。您可以根據 Cloud Storage 位置和 bucket ID 規則運算式,加入或排除 bucket。
        {
          "name":"projects/PROJECT_ID/locations/global/intelligenceConfig",
          "editionConfig":"EDITION_CONFIGURATION",
          "filter":{
            "includedCloudStorageBuckets":{
                "bucketIdRegexes":[
                  "INCLUDED_BUCKET_ID_REGEX",
                    ...]
            },
            "excludedCloudStorageBuckets":{
                "bucketIdRegexes":[
                  "EXCLUDED_BUCKET_ID_REGEX",
                    ...]
            },
            "includedCloudStorageLocations":{
                "locations":[
                  "INCLUDED_BUCKET_LOCATION",
                    ...]
            },
            "excludedCloudStorageLocations":{
                "locations":[
                  "EXCLUDED_BUCKET_LOCATION",
                    ...]
            }
          }
        }
      

    其中:

    • PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project。
    • EDITION_CONFIGURATION 是 Storage Intelligence 版本設定。
    • 選用:INCLUDED_BUCKET_ID_REGEX 是規則運算式,用來指定要納入哪些 bucket ID。您可以指定一或多個規則運算式做為清單。
    • 選用:EXCLUDED_BUCKET_ID_REGEX 是規則運算式,用來指定要排除的 bucket ID。您可以指定一或多個規則運算式做為清單。
    • 選用:INCLUDED_BUCKET_LOCATION 是您要在 Storage Intelligence 設定中納入 bucket 的位置。您可以指定一或多個位置做為清單。
    • 選用:EXCLUDED_BUCKET_LOCATION 是要從 Storage Intelligence 設定中排除 bucket 的位置。您可以指定一或多個位置,並以清單形式呈現。
  3. 以下各節說明如何更新專案、資料夾或組織的 Storage Intelligence 設定。請使用下列任一方法更新 Storage Intelligence 設定。

    更新專案的 Storage Intelligence 設定

    使用 cURL 呼叫 JSON API,更新專案的 Storage Intelligence 設定。

     curl -X PATCH \
       --data-binary @JSON_FILE_NAME \
       -H "Authorization: Bearer $(gcloud auth print-access-token)" \
       -H "Content-Type: application/json" \
       "https://storage.googleapis.com/v2/projects/PROJECT_ID/locations/global/intelligenceConfig?updateMask=UPDATE_MASK"
    

    其中:

    • PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project
    • UPDATE_MASK 是以半形逗號分隔的欄位名稱清單,列出這項要求更新的欄位。這些欄位採用 FieldMask 格式,屬於 IntelligenceConfig 資源。

    更新資料夾的 Storage Intelligence 設定

    使用 cURL 呼叫 JSON API,更新資料夾的 Storage Intelligence 設定。

     curl -X PATCH \
       --data-binary @JSON_FILE_NAME \
       -H "Authorization: Bearer $(gcloud auth print-access-token)" \
       -H "Content-Type: application/json" \
       "https://storage.googleapis.com/v2/folders/FOLDER_ID/locations/global/intelligenceConfig?updateMask=UPDATE_MASK"
    

    其中:

    • FOLDER_ID 是 Google Cloud 資料夾 ID。資料夾 ID 為數字,例如 123456789012
    • UPDATE_MASK 是以半形逗號分隔的欄位名稱清單,列出這項要求更新的欄位。這些欄位採用 FieldMask 格式,屬於 IntelligenceConfig 資源的一部分。

    更新機構的 Storage Intelligence 設定

    使用 cURL 呼叫 JSON API,更新組織的 Storage Intelligence 設定。

     curl -X PATCH \
       --data-binary @JSON_FILE_NAME \
       -H "Authorization: Bearer $(gcloud auth print-access-token)" \
       -H "Content-Type: application/json" \
       "https://storage.googleapis.com/v2/organizations/ORGANIZATION_ID/locations/global/intelligenceConfig?updateMask=UPDATE_MASK"
    

    其中:

    • ORGANIZATION_ID 是 Google Cloud 組織 ID。組織 ID 為數字,例如 79293024087
    • UPDATE_MASK 是這項要求更新的欄位名稱清單,以半形逗號分隔。這些欄位採用 FieldMask 格式,屬於 IntelligenceConfig 資源。

停用 Storage Intelligence

控制台

  1. 前往 Google Cloud 控制台的 Storage Intelligence「Configuration」(設定) 頁面。

    前往「設定」

  2. 選取頁面頂端的專案挑選器。

  3. 在「Select a resource」(選取資源) 對話方塊中,選取要停用 Storage Intelligence 的資源。

  4. 在「總覽」部分中,按一下「狀態」欄位旁的「停用」。

  5. 在隨即出現的對話方塊中輸入「停用」,然後按一下「停用」。

指令列

  1. 在 Google Cloud 控制台啟用 Cloud Shell。

    啟用 Cloud Shell

    Google Cloud 控制台底部會開啟 Cloud Shell 工作階段,並顯示指令列提示。Cloud Shell 是已安裝 Google Cloud CLI 的殼層環境,並已設定適用於您目前專案的值。工作階段可能要幾秒鐘的時間才能初始化。

  2. 如要停用資源的 Storage Intelligence 設定,請使用 gcloud storage intelligence-configs disable 指令,並搭配下列其中一個標記:

    • --project:停用專案的 Storage Intelligence 設定。這個值是專案 ID。例如:my-project。

    • --sub-folder:停用資料夾的 Storage Intelligence 設定。值為資料夾 ID。例如:1234567890。

    • --organization:為機構停用 Storage Intelligence 設定。這個值是組織 ID。例如:9876546738。

      舉例來說,下列指令會停用名為 my-project 的專案的 Storage Intelligence 設定:

      gcloud storage intelligence-configs disable --project=PROJECT_ID

      其中 PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project。

REST API

JSON API

  1. 安裝並初始化 gcloud CLI,以便為 Authorization 標頭產生存取權杖。

  2. 如要停用資源的 Storage Intelligence,請參閱下列各節,瞭解詳細方法。

    停用專案的 Storage Intelligence

    使用 cURL 呼叫 JSON API,為專案停用 Storage Intelligence。

    curl -X PATCH \
     -H "Content-Type: application/json" \
     -d '{
          "edition_config": "DISABLED"
         }' \
     -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/v2/projects/PROJECT_ID/locations/global/intelligenceConfig?updateMask=edition_config"

    其中:
    PROJECT_ID 是 Google Cloud 專案 ID。專案 ID 為英數字元,例如 my-project。

    停用資料夾的 Storage Intelligence

    使用 cURL 呼叫 JSON API,停用資料夾的 Storage Intelligence。

    curl -X PATCH \
      -H "Content-Type: application/json" \
      -d '{
        "edition_config": "DISABLED"
      }' \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/v2/folders/FOLDER_ID/locations/global/intelligenceConfig?updateMask=edition_config"
    

    其中:
    FOLDER_ID 是 Google Cloud 資料夾 ID。資料夾 ID 為數字,例如 123456789012。

    為組織停用 Storage Intelligence

    使用 cURL 呼叫 JSON API,停用組織的 Storage Intelligence。

    curl -X PATCH \
      -H "Content-Type: application/json" \
      -d '{
        "edition_config": "DISABLED"
      }' \
      -H "Authorization: Bearer $(gcloud auth print-access-token)" \
      "https://storage.googleapis.com/v2/organizations/ORGANIZATION_ID/locations/global/intelligenceConfig?updateMask=edition_config"

    其中:
    ORGANIZATION_ID 是 Google Cloud 組織 ID。組織 ID 為數字,例如 79293024087。

後續步驟