配置和管理存储空间分析情报

本页面介绍了如何为资源配置、查看、更新和停用Storage Intelligence

所需的角色

如需获得配置和管理 Storage Intelligence 所需的权限,请让您的管理员为您授予项目、文件夹或组织的 Storage Admin (roles/storage.admin) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

此预定义角色包含配置和管理Storage Intelligence所需的权限。如需查看所需的确切权限,请展开所需权限部分:

所需权限

配置和管理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. 在 Trusted Cloud 控制台中,前往 Storage Intelligence 配置页面。

    转到“配置”

  2. 点击启用Storage Intelligence

  3. 配置Storage Intelligence对话框中,选择要为其配置Storage Intelligence的资源

  4. 点击继续

  5. 可选:如需在Storage Intelligence配置中包含或排除特定存储桶,请执行以下操作:

    1. 如需选择特定位置的存储桶,请使用过滤条件类型菜单。如需包含或排除存储桶,请从位置菜单中选择相应位置。如需了解详情,请参阅按位置过滤

    2. 如需按名称选择 Cloud Storage 存储桶,请使用过滤条件类型菜单。如需包含或排除存储桶,请指定存储桶名称的正则表达式,然后点击添加正则表达式。如需了解详情,请参阅按存储桶名称过滤

  6. 点击启用此配置

命令行

  1. In the Trusted Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Trusted Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如需配置Storage Intelligence,请将 gcloud alpha 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 alpha storage intelligence-configs enable --project=PROJECT_ID

      其中,PROJECT_ID 是项目 ID。

    如需在Storage Intelligence配置中包含或排除特定存储桶,请使用以下任意一个标志:

    • --exclude-bucket-regexes:要从 Storage Intelligence 配置中排除的存储桶 ID 正则表达式的列表。
    • --include-bucket-regexes:要纳入Storage Intelligence配置的存储桶 ID 正则表达式的列表。

    例如,如需排除名称中包含 colddata 的所有存储桶,请使用以下命令:

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

    例如,如需排除名为 colddata 的存储桶,请使用以下命令:

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

    例如,如需排除名为 colour 或 color 的存储桶,请使用以下命令:

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

    如需在Storage Intelligence配置中根据存储桶的位置包含或排除存储桶,请使用以下任意一个标志:

    • --exclude-locations:要从Storage Intelligence配置中排除的位置的列表。
    • --include-locations:要纳入Storage Intelligence配置的位置列表。

    例如:

    gcloud alpha storage intelligence-configs enable --sub-folder=123456 --include-locations=us-east1,us-west1
  3. 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 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project
        • FOLDER_ID 是 Trusted Cloud 文件夹 ID。文件夹 ID 是数字,例如 123456789012
        • ORGANIZATION_ID 是 Trusted Cloud 组织 ID。组织 ID 是数字,例如 123456789012
      2. 配置 editionConfig 字段。如需了解详情,请参阅 版本配置
      3. 可选:配置 filter 对象。您可以根据 Cloud Storage 位置存储桶 ID 正则表达式包含或排除存储桶。
          {
            "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 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project
      • EDITION_CONFIGURATION 是Storage Intelligence版本配置
      • 可选:INCLUDED_BUCKET_ID_REGEX 是一个正则表达式,用于指定要包含哪些存储桶 ID。您可以指定一个或多个正则表达式(以列表形式)。
      • 可选:EXCLUDED_BUCKET_ID_REGEX 是一个正则表达式,用于指定要排除哪些存储桶 ID。您可以指定一个或多个正则表达式(以列表形式)。
      • 可选:INCLUDED_BUCKET_LOCATION 是您希望在Storage Intelligence配置中包含的存储桶的位置。您可以以列表形式指定一个或多个位置。
      • 可选:EXCLUDED_BUCKET_LOCATION 是您要从Storage Intelligence配置中排除存储桶的位置。您可以以列表形式指定一个或多个位置。
    3. 以下部分介绍了如何使用 REST API 为项目、文件夹或组织配置Storage Intelligence。您还可以使用 REST API 配置 Storage Intelligence 30 天入门级试用。使用以下任意一种方法配置 Storage Intelligence 或 Storage Intelligence 30 天入门级试用。

      为项目配置Storage Intelligence

      使用 cURL,通过请求为项目配置Storage Intelligence来调用 JSON API

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

      其中:

      • PROJECT_ID 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project
      • UPDATE_MASK 是此请求更新的字段名称的英文逗号分隔列表。这些字段采用 FieldMask 格式,并且是 IntelligenceConfig 资源的一部分。

      为文件夹配置Storage Intelligence

      使用 cURL,通过为文件夹配置Storage Intelligence的请求调用 JSON API

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

      其中:

      • FOLDER_ID 是 Trusted Cloud 文件夹 ID。文件夹 ID 是数字,例如 123456789012
      • UPDATE_MASK 是此请求更新的字段名称的英文逗号分隔列表。这些字段采用 FieldMask 格式,并且是 IntelligenceConfig 资源的一部分。

      为组织配置Storage Intelligence

      使用 cURL,通过请求为组织配置Storage Intelligence来调用 JSON API

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

      其中:

      • ORGANIZATION_ID 是 Trusted Cloud 组织 ID。组织 ID 是数字,例如 79293024087
      • UPDATE_MASK 是此请求更新的字段名称的英文逗号分隔列表。这些字段采用 FieldMask 格式,并且是 IntelligenceConfig 资源的一部分。

查看Storage Intelligence配置

控制台

  1. 在 Trusted Cloud 控制台中,前往 Storage Intelligence 配置页面。

    转到“配置”

  2. 选择页面顶部的项目选择器。

  3. 选择资源对话框中,选择要查看Storage Intelligence配置的资源

如果资源已配置Storage Intelligence,则状态字段会显示 Enabled。对于未配置Storage Intelligence的资源,系统会显示配置Storage Intelligence按钮。

命令行

  1. In the Trusted Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Trusted Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如需查看资源的Storage Intelligence配置,请使用 gcloud alpha 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 alpha storage intelligence-configs describe --project=PROJECT_ID

      其中,PROJECT_ID 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project

  3. REST API

    JSON API

    1. 安装并初始化 gcloud CLI,以便为 Authorization 标头生成访问令牌。

    2. 以下部分详细介绍了查看资源的Storage Intelligence配置的方法。

      查看项目的 Storage Intelligence 配置

      使用 cURL,通过查看项目的Storage Intelligence配置请求调用 JSON API

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

      其中:

      PROJECT_ID 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project

      查看文件夹的 Storage Intelligence 配置

      使用 cURL,通过查看文件夹的Storage Intelligence配置的请求调用 JSON API

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

      其中:

      FOLDER_ID 是 Trusted Cloud 文件夹 ID。文件夹 ID 是数字,例如 123456789012

      查看组织的 Storage Intelligence 配置

      使用 cURL,通过请求查看组织的Storage Intelligence配置来调用 JSON API

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

      其中:

      ORGANIZATION_ID 是 Trusted Cloud 组织 ID。组织 ID 是数字,例如 79293024087

更新Storage Intelligence配置

控制台

  1. 在 Trusted Cloud 控制台中,前往 Storage Intelligence 配置页面。

    转到“配置”

  2. 选择页面顶部的项目选择器。

  3. 选择资源对话框中,选择要更新Storage Intelligence配置的资源

  4. 概览部分,根据您的需求修改任何可修改的配置选项。例如,您可以针对某个资源停用Storage Intelligence,或将版本配置更改为 Inherit from parent,或更改存储桶过滤条件

命令行

  1. In the Trusted Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Trusted Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如需更新资源的Storage Intelligence配置,请将 gcloud alpha 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 alpha storage intelligence-configs update --project=PROJECT_ID

      其中,PROJECT_ID 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project

  3. 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 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project
        • FOLDER_ID 是 Trusted Cloud 文件夹 ID。文件夹 ID 是数字,例如 123456789012
        • ORGANIZATION_ID 是 Trusted Cloud 组织 ID。组织 ID 是数字,例如 123456789012
      2. 配置 editionConfig 字段。如需了解详情,请参阅 版本配置
      3. 可选:配置 filter 对象。您可以根据 Cloud Storage 位置存储桶 ID 正则表达式包含或排除存储桶。
          {
            "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 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project
      • EDITION_CONFIGURATION 是Storage Intelligence版本配置
      • 可选:INCLUDED_BUCKET_ID_REGEX 是一个正则表达式,用于指定要包含哪些存储桶 ID。您可以指定一个或多个正则表达式(以列表形式)。
      • 可选:EXCLUDED_BUCKET_ID_REGEX 是一个正则表达式,用于指定要排除哪些存储桶 ID。您可以指定一个或多个正则表达式(以列表形式)。
      • 可选:INCLUDED_BUCKET_LOCATION 是您希望在Storage Intelligence配置中包含的存储桶的位置。您可以以列表形式指定一个或多个位置。
      • 可选:EXCLUDED_BUCKET_LOCATION 是您要从Storage Intelligence配置中排除存储桶的位置。您可以以列表形式指定一个或多个位置。
    3. 以下部分介绍了如何更新项目、文件夹或组织的Storage Intelligence配置。使用以下方法之一更新Storage Intelligence配置。

      更新项目的Storage Intelligence配置

      使用 cURL,通过请求更新项目的Storage Intelligence配置来调用 JSON API

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

      更新文件夹的Storage Intelligence配置

      使用 cURL,通过更新文件夹的Storage Intelligence配置的请求调用 JSON API

      其中:

      • PROJECT_ID 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project
      • UPDATE_MASK 是此请求更新的字段名称的英文逗号分隔列表。这些字段采用 FieldMask 格式,并且是 IntelligenceConfig 资源的一部分。

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

      其中:

      • FOLDER_ID 是 Trusted Cloud 文件夹 ID。文件夹 ID 是数字,例如 123456789012
      • UPDATE_MASK 是此请求更新的字段名称的英文逗号分隔列表。这些字段采用 FieldMask 格式,并且是 IntelligenceConfig 资源的一部分。

      更新组织的Storage Intelligence配置

      使用 cURL,通过更新组织的Storage Intelligence配置的请求调用 JSON API

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

      其中:

      • ORGANIZATION_ID 是 Trusted Cloud 组织 ID。组织 ID 是数字,例如 79293024087
      • UPDATE_MASK 是此请求更新的字段名称的英文逗号分隔列表。这些字段采用 FieldMask 格式,并且是 IntelligenceConfig 资源的一部分。

停用Storage Intelligence

控制台

  1. 在 Trusted Cloud 控制台中,前往 Storage Intelligence 配置页面。

    转到“配置”

  2. 选择页面顶部的项目选择器。

  3. 选择资源对话框中,选择要停用Storage Intelligence的资源。

  4. 概览部分中,点击状态字段旁边的已启用

  5. 在随即显示的对话框中,输入停用,然后点击停用

命令行

  1. In the Trusted Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Trusted Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. 如需为资源停用Storage Intelligence配置,请将 gcloud alpha 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 alpha storage intelligence-configs disable --project=PROJECT_ID

      其中,PROJECT_ID 是 Trusted Cloud 项目 ID。项目 ID 为字母数字,例如 my-project

  3. REST API

    JSON API

    1. 安装并初始化 gcloud CLI,以便为 Authorization 标头生成访问令牌。

    2. 以下部分详细介绍了停用资源的Storage Intelligence的方法。

      为项目停用 Storage Intelligence

      使用 cURL,通过为项目更新Storage Intelligence的请求调用 JSON API

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

      其中,PROJECT_ID 是 Trusted Cloud 项目 ID。
      项目 ID 为字母数字,例如 my-project

      为文件夹停用Storage Intelligence

      使用 cURL,通过为文件夹更新Storage Intelligence的请求调用 JSON API

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

      其中:
      FOLDER_ID 是 Trusted Cloud 文件夹 ID。文件夹 ID 是数字,例如 123456789012

      为组织停用Storage Intelligence

      使用 cURL,通过请求为组织停用Storage Intelligence来调用 JSON API

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

      其中:
      ORGANIZATION_ID 是 Trusted Cloud 组织 ID。组织 ID 是数字,例如 79293024087

后续步骤