Stay organized with collectionsSave and categorize content based on your preferences.
This page describes how to create and manage inventory report configurations and
generated inventory reports, so you can get a high level summary of all your
objects' metadata in a given bucket. For an overview of inventory reports, see
theinventory reports overview documentation.
Before you begin
Get required roles
In order to get the required permissions for creating and managing inventory
reports, ask your administrator to grant you the following IAM
roles on the project or source and destination buckets with which you'll be
managing inventory reports.
To create and manage inventory report configurations:
roles/storage.adminon the source bucket and destination bucket
roles/storageinsights.adminon the project
To read and download inventory reports:
roles/storage.objectVieweron the destination bucket
roles/storageinsights.vieweron the project
These predefined roles contain the permissions required to create and manage
inventory reports and configurations. To see the exact permissions that are
required, expand theRequired permissionssection:
Required permissions
To create and manage inventory report configurations:
storage.buckets.geton the source bucket
storage.objects.liston the source bucket
storage.buckets.getObjectInsightson the source bucket
storage.buckets.geton the destination bucket
storage.objects.createon the destination bucket
storageinsights.reportConfigs.deleteon the project
storageinsights.reportConfigs.geton the project
storageinsights.reportConfigs.createon the project
storageinsights.reportConfigs.liston the project
storageinsights.reportConfigs.updateon the project
For instructions on using roles to control access to buckets,
seeUse IAM. For instructions on using roles to control
access to projects, seeManage access.
Enable the Storage Insights API
Console
To enable thestorageinsights.googleapis.comAPI, follow the
instructions inEnabling services.
Command line
To enable the Storage Insights API in your
current project, run the following command:
In the list of buckets, click the name of the bucket you'd like to use as
thesource bucket.
On theBucket detailspage, click theInventory reportstab.
ClickCreate report configuration.
In theIdentify your report configurationsection, create a display
name for the inventory report configuration. The display name can contain
up to 256 characters.
In theChoose metadata fieldssection, select themetadata fieldsyou want to include in your inventory reports.
ClickContinue.
In theChoose a file formatsection, select the file format in
which you'd like to generate inventory reports.
In theChoose a destination bucketsection, select the bucket you'd
like to use as adestination bucket.
In theEnter destination path (optional)section, you can optionally
specify adestination pathwhere inventory reports will be
generated.
In theScheduling optionssection, specify the frequency, start date,
and end date for generating reports.
ClickCreate.
TheReport configuration detailspage is displayed. The metadata of
generated inventory reports will appear on the page.
Command line
To create an inventory report configuration, run thegcloud storage insights inventory-reports createcommand:
SOURCE_BUCKET_URLwith the URL of the source
bucket. For example,gs://my_example_source_bucket.
SEPARATORwith the character used to separate
the records in the inventory report CSV file. Must be either\nor\r\n. Default value is\n. Optional. If the--csv-separatorflag is used,--parquetcannot be used.
DELIMITERwith the delimiter that separates the
fields in the inventory report CSV file. The value can
include one character and cannot be the same value asSEPARATOR. Default value is,. Optional.
If--csv-delimiteris used,--parquetcannot be used.
--[no]-csv-headerwith the flag that
indicates whether or not headers are included in the inventory report
CSV file. Use--csv-headerto include
headers and--no-csv-headerto exclude headers. If
either flag is used,--parquetcannot be used.
DISPLAY_NAMEwith the editable name of the
inventory report configuration. Optional.
--parquetwith the flag that generates
inventory reports in Apache Parquet format instead of
CSV. If used,--csv-delimiter,--csv-separator,
and--[no-]csv-headercannot be used.
DESTINATION_PATHwith the bucket or folder
in the bucket where inventory reports will be generated. For example,gs://my_example_destination_bucketorgs://my_example_destination_bucket/path/to/inventory/report.
When you specify a path to a folder within a bucket,
you can use keywords in the path, which are substituted with their
corresponding values when the report is generated. This enables you
to generate reports in aHive partitioned formatso you can
load or query the data in BigQuery without additional processing.
METADATA_FIELDwith a comma-separated list
ofmetadata fieldsyou want included in the inventory report.
START_DATEwith the UTC date on which you
want to start generating inventory reports. For example,2022-01-15.
FREQUENCYwith how often you want
inventory reports to be generated. Values aredailyorweekly.
END_DATEwith the UTC date after which you
want to stop generating inventory reports. Must be a value after theSTART_DATE. For example, if you
specify2022-02-15, inventory reports will no longer be generated
as of February 16, 2022.
DISPLAY_NAMEwith the editable display name
of the inventory report configuration. Can contain up to 256
characters.
FREQUENCYwith the frequency for generating
inventory reports. Values areDAILYorWEEKLY.
START_DATEwith the UTC date on which you
want to start generating inventory reports. Cannot be the current
date or any past date. Value must be an object containing the keysday,month, andyear. For example:{"day": 15, "month": 8, "year": 2022}.
END_DATEwith the UTC date after which you
want to stop generating inventory reports. Value must be an object
containing the keysday,month, andyear. For example, if you
specify{"day": 15, "month": 9, "year": 2022}, inventory reports
are no longer generated as of September 16, 2022.
RECORD_SEPARATORwith the character used to
separate the records in the inventory report CSV file. Must be
either\nor\r\n. Default value is\n. This field is
optional.
DELIMITERwith the delimiter that separates
the fields in the inventory report CSV file. The
value can include one character and cannot be the same as theRECORD_SEPARATOR. Default value is,.
This field is optional.
HEADER_REQUIREDwith the boolean that
indicates whether or not headers are included in the CSV file.
This field is optional.
SOURCE_BUCKET_NAMEwith the name of thesource bucketthat contains the objects you want to generate
inventory reports for. For example,my_example_bucket.
METADATA_FIELDwith a comma-separated list ofmetadata fieldsyou want included in the inventory report.
DESTINATION_BUCKET_NAMEwith the name of
thedestination bucketwhere generated inventory reports
are generated and stored. For example,my_example_destination_bucket.
DESTINATION_PATHwith the path in the
destination bucket where generated inventory reports are generated.
This field is optional.
When you specify a path to a folder within a bucket,
you can use keywords in the path, which are substituted with their
corresponding values when the report is generated. This enables you
to generate reports in aHive partitioned formatso you can
load or query the data in BigQuery without additional processing.
For example, the following code sample creates an inventory report
configuration named "Example inventory report configuration" that
generates reports at a weekly frequency:
JSON_FILE_NAMEwith the path to the JSON
file you created in the previous step.
YOUR_PROJECTwith the name of the project
in which your source and destination buckets reside.
LOCATIONwith thelocationof the
source and destination buckets. For example,us-west1.
Grant required roles to the service agent
A project-levelservice agentis automatically created the first time you set up an inventory report
configuration. The service agent follows the naming formatservice-PROJECT_NUMBER@gcp-sa-storageinsights.iam.gserviceaccount.comand
appears on theIAM page of the Google Cloud consolewhen you select theInclude Google-provided role grantscheckbox.
To enable Storage Insights to generate and write inventory reports, ask your administrator to
grant the service agent the following IAM roles:
roles/storage.insightsCollectorServiceon the source bucket, which includes thestorage.buckets.getObjectInsightsandstorage.buckets.getpermissions
roles/storage.objectCreatoron the destination bucket, which
includes thestorage.objects.createpermission
For instructions on granting roles, seeUse IAM.
You can grant theroles/storage.insightsCollectorServicerole by using
the Google Cloud console or the Google Cloud CLI. For example:
In the list of buckets, click the name of the source bucket that
contains the inventory report configuration you want to edit.
In your source bucket'sBucket detailspage, click theInventory reportstab.
Click the configuration name of the inventory report configuration you
want to edit.
In theReport configuration detailspage that appears, edit the
properties you desire by using theeditEditbutton.
Command line
To edit an inventory report configuration, follow the steps below:
To find the name of the inventory report configuration you want to
edit, list all the inventory configurations in the source bucket by
using thegcloud storage insights inventory-reports listcommand:
SOURCE_BUCKETwith the URL of the source
bucket that contains the inventory report configuration.
EXPRESSIONwith a boolean filter to apply to
each resource item to be listed. If the expression evaluates True,
the item is listed. For more details and examples of filter
expressions, run$ gcloud topic filters.
SIZEwith the maximum number of resources per
page. The default is 50.
FIELDwith a comma-separated list of resource
field key names to sort by. The default order is ascending. Prefix a
field with~for descending order on that field.
Edit the inventory report configuration fields you want to update by
using thegcloud storage insights inventory-reports updatecommand. The following example updates the inventory report
configuration to generate inventory reports daily in Apache Parquet
format:
importcom.google.cloud.storageinsights.v1.ReportConfig;importcom.google.cloud.storageinsights.v1.ReportConfigName;importcom.google.cloud.storageinsights.v1.StorageInsightsClient;importcom.google.cloud.storageinsights.v1.UpdateReportConfigRequest;importcom.google.protobuf.FieldMask;importjava.io.IOException;publicclassEditInventoryReportConfig{publicstaticvoideditInventoryReportConfig(StringprojectId,Stringlocation,StringinventoryReportConfigUuid)throwsIOException{try(StorageInsightsClientstorageInsightsClient=StorageInsightsClient.create()){ReportConfigNamename=ReportConfigName.of(projectId,location,inventoryReportConfigUuid);ReportConfigreportConfig=storageInsightsClient.getReportConfig(name);// Set any other fields you want to update hereReportConfigupdatedReportConfig=reportConfig.toBuilder().setDisplayName("Updated Display Name").build();storageInsightsClient.updateReportConfig(UpdateReportConfigRequest.newBuilder()// Add any fields that you want to update to the update mask, in snake case.setUpdateMask(FieldMask.newBuilder().addPaths("display_name").build()).setReportConfig(updatedReportConfig).build());System.out.println("Edited inventory report config with name "+name);}}}
REST APIs
JSON API
To edit an inventory report configuration, complete the following steps:
YOUR_PROJECTwith the name of the project
in which your source and destination buckets reside.
LOCATIONwith thelocationof the
source and destination buckets. For example,us-west1.
BUCKET_NAMEwith the name of the source
bucket that contains the inventory report configurations you want
to edit.
Create a JSON file that includes changes to the properties you want
to edit. The following example updates the inventory report
configuration to generate inventory reports daily in Apache Parquet
format:
SOURCE_BUCKETwith the URL of the source
bucket that contains the inventory report configuration.
EXPRESSIONwith a boolean filter to apply to
each resource item to be listed. If the expression evaluates True,
the item is listed. For more details and examples of filter
expressions, run$ gcloud topic filters.
SIZEwith the maximum number of resources per
page. The default is 50.
FIELDwith a comma-separated list of resource
field key names to sort by. The default order is ascending. Prefix a
field with~for descending order on that field.
importcom.google.cloud.storageinsights.v1.LocationName;importcom.google.cloud.storageinsights.v1.ReportConfig;importcom.google.cloud.storageinsights.v1.StorageInsightsClient;importjava.io.IOException;publicclassListInventoryReportConfigs{publicstaticvoidlistInventoryReportConfigs(StringprojectId,Stringlocation)throwsIOException{try(StorageInsightsClientstorageInsightsClient=StorageInsightsClient.create()){System.out.println("Printing inventory report configs in project "+projectId+" and location "+location);for(ReportConfigconfig:storageInsightsClient.listReportConfigs(LocationName.of(projectId,location)).iterateAll()){System.out.println(config.getName());}}}}
In the list of buckets, click the name of the destination bucket that
contains the inventory report you want to download.
On theBucket detailspage, make sure theObjectstab is
selected.
Clickfile_downloadDownloadassociated with the inventory report you want to download.
If you don't know the destination bucket, you can also download an
inventory report through the inventory report configuration from which it
was generated:
In the Google Cloud console, go to the Cloud StorageBucketspage.
In the list of buckets, click the name of the source bucket containing
the inventory report configuration that generated the report you want to
download.
On theBucket detailspage, click the configuration name of the
inventory report configuration.
On theReport configuration detailspage that appears, navigate to
theInventory report historysection, then click the destination
object path of the inventory report you want to download.
TheBucket detailspage appears for the destination bucket that
contains the inventory report.
Clickfile_downloadDownloadassociated with the inventory report you want to download.
Download report shards
To download an inventory report that's been split into one or moreshards, complete the following steps:
In the Google Cloud console, go to the Cloud StorageBucketspage.
In the list of buckets, click the name of the destination bucket you
specified when you created the inventory report configuration.
On theBucket detailspage, check for the presence of amanifest file. The presence of a manifest file indicates that
all the shards of an inventory report have been generated.
An example manifest file name isfc95c52f-157a-494f-af4a-d4a53a69ba66_2022-11-30T00:00_manifest.json.
In the destination bucket, clickfile_downloadDownloadassociated with the manifest file. Note the names of the shard files you
want to download from thereport_shards_file_namesfield.
In the destination bucket, clickfile_downloadDownloadassociated with the shard files you want to download.
Command line
Download individual reports
To download an inventory report, complete the following steps:
To list all the inventory reports that have been generated by an
inventory report configuration and retrieve theirREPORT_DETAIL_ID,
use thegcloud storage insights inventory-reports details listcommand:
CONFIG_NAMEwith the unique name of the
inventory report configuration, in the formatprojects/PROJECT/locations/LOCATION/reportConfigs/REPORT_CONFIG_UUID.
EXPRESSIONwith a boolean filter to apply to each
resource item to be listed. If the expression evaluates True, then that
item is listed. For more details and examples of filter expressions,
run$ gcloud topic filters.
SIZEwith the maximum number of resources per
page. The default is 50.
FIELDwith a comma-separated list of resource
field key names to sort by. The default order is ascending. Prefix a
field with~for descending order on that field.
If successful, the command returns output similar to the following:
To download an inventory report, you need to first retrieve thereportPathPrefixproperty of the ReportDetail object. To get thereportPathPrefixof a report, use thegcloud storage insights inventory-reports details describecommand:
ReplaceREPORT_DETAIL_NAMEwith the name of
the inventory report in the formatprojects/PROJECT/locations/LOCATION/reportConfigs/REPORT_CONFIG_UUID/reportDetails/REPORT_DETAIL_ID.
Download report shards
To download an inventory report that's been split into one or moreshards, complete the following steps:
Download the inventory reportmanifest fileby using thegcloud storage cpcommand:
BUCKET_NAMEwith the name of the destination
bucket.
SHARD_FILE_NAMEwith the URL-encoded name of
the shard file you want to download. For example,fc95c52f-157a-494f-af4a-d4a53a69ba66_2022-11-30T00:54_0.csv.
DOWNLOAD_PATHwith the path to your file
system where you want to save the inventory report to. For example,./example_report.csv.
importcom.google.cloud.storageinsights.v1.ReportConfig;importcom.google.cloud.storageinsights.v1.ReportConfigName;importcom.google.cloud.storageinsights.v1.ReportDetail;importcom.google.cloud.storageinsights.v1.StorageInsightsClient;importjava.io.IOException;publicclassGetInventoryReportNames{publicstaticvoidgetInventoryReportNames(StringprojectId,Stringlocation,StringreportConfigUuid)throwsIOException{try(StorageInsightsClientstorageInsightsClient=StorageInsightsClient.create()){ReportConfigconfig=storageInsightsClient.getReportConfig(ReportConfigName.of(projectId,location,reportConfigUuid));Stringextension=config.hasCsvOptions()?"csv":"parquet";System.out.println("You can use the Google Cloud Storage Client "+"to download the following objects from Google Cloud Storage:");for(ReportDetailreportDetail:storageInsightsClient.listReportDetails(config.getName()).iterateAll()){for(longindex=reportDetail.getShardsCount()-1;index>=0;index--){System.out.println(reportDetail.getReportPathPrefix()+index+"."+extension);}}}}}
REST APIs
JSON API
Download individual reports
To download an inventory report, complete the following steps:
DOWNLOAD_PATHwith the path to your local
file system where you want to save your object. For example,Desktop/dog.png.
BUCKET_NAMEwith the name of the
destination bucket containing the inventory report. For example,my-bucket.
SHARD_FILE_NAMEwith the URL-encoded name
of the shard file you want to download. For example,fc95c52f-157a-494f-af4a-d4a53a69ba66_2022-11-30T00:54_0.csv.
Delete an inventory report configuration
Console
To delete an inventory report configuration, complete the following steps:
In the Google Cloud console, go to the Cloud StorageBucketspage.
ReplaceCONFIG_NAMEwith the unique name of the
inventory report configuration, in the formatprojects/PROJECT/locations/LOCATION/reportConfigs/REPORT_CONFIG_UUID.
The--forceflag deletes the metadata for all inventory reports
generated by the given inventory report configuration. The
inventory report objects themselves will not be deleted.
importcom.google.cloud.storageinsights.v1.ReportConfigName;importcom.google.cloud.storageinsights.v1.StorageInsightsClient;importjava.io.IOException;publicclassDeleteInventoryReportConfig{publicstaticvoiddeleteInventoryReportConfig(StringprojectId,Stringlocation,StringinventoryReportConfigUuid)throwsIOException{try(StorageInsightsClientstorageInsightsClient=StorageInsightsClient.create()){ReportConfigNamename=ReportConfigName.of(projectId,location,inventoryReportConfigUuid);storageInsightsClient.deleteReportConfig(name);System.out.println("Deleted inventory report config with name "+name);}}}
REST APIs
JSON API
To delete an inventory report configuration, complete the following steps:
YOUR_PROJECTwith the name of the project
in which your source and destination buckets reside.
LOCATIONwith thelocationof the
source and destination buckets. For example,us-west1.
REPORT_CONFIG_UUIDwith the auto-generated
UUID of the inventory report configuration you want to delete.
Theforcequery parameter deletes the metadata for all
inventory reports generated by the given inventory report configuration.
The inventory report objects themselves will not be deleted.
Advanced: Generate inventory reports in a Hive partitioned format
When you create an inventory report configuration, you can specify a
destination path, which is a location in your destination bucket where inventory
reports will be generated. This enables you to generate inventory reports in aHive partitioned format.
You specify a destination path by using placeholderkeywords.
Keywords in the destination path are substituted with their corresponding values
when the inventory report is generated. For example, the destination
pathconfig={{report-config-id}}/date={{date}}can resolve toconfig=1A34-F2E456-12B456-1C3D/date=2022-05-20.
Destination path keywords
You can specify the keywordsreport-config-id,date, ordatetime, enclosed within {{ and
}}, where:
report-config-idis the UUID of the inventory report configuration.
dateis the date on which the inventory report is generated. Follows the
ISO 8601 format.
datetimeis the date and time on which the inventory report is generated.
Follows the ISO 8601 format.
Keywords can be specified by using any of the following tools:
When using the Google Cloud console, specify keywords in theEnter destination path (optional)section. This section appears when youcreate an inventory report configuration.
When using the Google Cloud CLI, specify placeholder keywords by using the--destinationflag.
When using the JSON API, specify placeholder keywords in thestorage_destination_options.destination_pathfield of the ReportConfig
object.
Access control and security
The following recommendations and considerations relate to the security and
usage of inventory reports and configurations:
We recommend that users with theroles/storage.adminrole also have thestorageinsights.reportConfigs.*permissions so they can maintain control
over the usage of all resources in their buckets, such as the reading of
objects and their metadata.
We recommend that you limit access to your inventory report resources by
granting thestorageinsights.reportConfigs.*permissions only to necessary
individuals.
Once an inventory report configuration has been created, it continues to
generate inventory reports even if the user who created the configuration no
longer has the required permissions. To stop generating inventory reports,
you caneditthe end date in the inventory report configuration ordeletethe configuration entirely.
What's next
If you encounter issues with generating inventory reports, refer toTroubleshootingfor help.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,[]]