For RESOURCE content types, table names in the dataset correspond to the
asset type name, assuming that asset type exists. For example, the
compute_googleapis_com_Instance table contains Compute Engine
instance metadata.
For non-RESOURCE content types, table names in the dataset correspond to the
RPC/REST content type names.
For example, ACCESS_POLICY.
To query resource standard metadata across resource types, use the table name
STANDARD_METADATA. This includes all fields except resource.DATA, which is
specific to each resource type.
Query asset metadata
Console
To query the asset metadata for your project, folder, or organization,
complete the following steps:
In the Google Cloud console, go to the Asset query tab on
the Asset Inventory page.
Change to the project, folder, or organization you want to query.
Click the Asset query tab.
To query asset metadata, either use a sample query or build your
own:
To use a sample, click an entry in the Query library tab to
preview the query. Click Apply to copy that sample into the
Edit query box, then either edit the query, or click
Run to execute it.
To build your own query, enter the query text directly into the
Edit query box, then click Run to execute it. To
assist in writing your own query, you can click a table in the
Select table pane to preview its schema and content. See
Query syntax to learn how to construct a query.
The asset metadata matching the query is shown in the
Query result tab.
Optional: To download the query result sets in CSV format, click
Export.
The maximum size of the CSV file is 2 MB. If the download
request fails because the file size exceeds this limit, a message
appears with instructions for exporting the full results.
TIMEOUT: Optional. The maximum time, in seconds, that a
client should wait for the query to complete before continuing. Use timeouts to asynchronously
run your query, and retrieve the results later with job
references.
Run the following command to get the names and asset types of the first two Compute Engine
instances in the my-project project.
gcloudassetquery\--project=my-project\--statement=" SELECT name, assetType FROM compute_googleapis_com_Instance LIMIT 2"
Finished job response
The following sample shows a response to the previous example query. The
response contains a job reference and tells you whether the job has
finished (done: true). If the job has finished, then the
queryResult object is populated with the appropriate data,
and the results are listed afterward.
If you set a timeout in your request, the query is performed
asynchronously and you are sent a response that indicates the job is
unfinished (done: false). These sorts of responses contain a
job reference and an unpopulated queryResult object:
TIMEOUT: Optional. The maximum time, in seconds, that a
client should wait for the query to complete before continuing. Use timeouts to asynchronously
run your query, and retrieve the results later with job
references.
PAGE_SIZE: Optional. The number of results to return per
page. The maximum is 500. If the value is set to 0 or a negative value, an
appropriate default is selected. A nextPageToken is returned to retrieve
subsequent results.
PAGE_TOKEN: Optional. Long request responses are separated
over multiple pages. When pageToken isn't specified, the first page is returned.
Subsequent pages can be called by using the previous response's nextPageToken as
the pageToken value.
The following sample shows a response to the previous example query. The
response contains a job reference and tells you whether the job has
finished ("done": true). If the job has finished, then the
queryResult object is populated with the appropriate
data.
Query results are split into rows, an array that contains
asset metadata, and schema, an object which describes the
schema for each asset in the rows array. This is done to
minimize duplication of field names and types in large responses.
Similarly, f and v are used in the
rows array instead of fields and
value to keep responses as small as possible.
If you set a timeout in your request, the query is performed
asynchronously and you are sent a response that indicates the job is
unfinished ("done": false). These sorts of responses contain
a job reference and an unpopulated queryResult object:
JOB_REFERENCE: The job reference value returned in
a previous response.
PAGE_TOKEN: Optional. Long request responses are separated
over multiple pages. When pageToken isn't specified, the first page is returned.
Subsequent pages can be called by using the previous response's nextPageToken as
the pageToken value.
Command examples
Run one of the following commands to get the results of a previously run query.
Query results are returned as Query Assets API responses. To export the results
to your own BigQuery table, specify a BigQuery destination in
the request. If you don't already have one, you must
create a BigQuery dataset before making
these requests.
BIGQUERY_PROJECT_ID: The ID of
the project that the BigQuery table is in that you want to export to.
DATASET_ID: The ID of the BigQuery
dataset.
TABLE_NAME: The BigQuery table that
you're exporting your metadata to. If it doesn't exist, it's created.
WRITE_METHOD: Specifies the behavior if the
BigQuery destination table or partition already exists. The following values are
supported:
write-empty: Default. If the existing table contains data, a duplicate error is returned in the
job result.
write-append: Appends data to the table or the latest partition.
write-truncate: Overwrites the entire table or all partitions data.
Example
Run the following command to get the names and asset types of the first two Compute Engine
instances in the my-project project, and export the results to the
my-table BigQuery table in the my-project project, overwriting
the entire table if it already exists.
gcloudassetquery\--project=my-project\--statement=" SELECT name, assetType FROM compute_googleapis_com_Instance LIMIT 2"\--bigquery-table=projects/my-project/datasets/my-dataset/tables/my-table\--write-disposition="write-truncate"
REST
HTTP method and URL:
POST https://cloudasset.googleapis.com/v1/SCOPE_PATH:queryAssets
BILLING_PROJECT_ID: The project ID that the
default Cloud Asset Inventory service agent is in that has permissions to manage your
BigQuery datasets and tables.
Read more about setting the billing project.
SQL_SELECT_QUERY: An SQL SELECT
query.
BIGQUERY_PROJECT_ID: The ID of
the project that the BigQuery table is in that you want to export to.
DATASET_ID: The ID of the BigQuery
dataset.
TABLE_NAME: The BigQuery table that
you're exporting your metadata to. If it doesn't exist, it's created.
WRITE_METHOD: Specifies the behavior if the
BigQuery destination table or partition already exists. The following values are
supported:
WRITE_EMPTY: Default. If the existing table contains data, a duplicate error is returned in the
job result.
WRITE_APPEND: Appends data to the table or the latest partition.
WRITE_TRUNCATE: Overwrites the entire table or all partitions data.
PAGE_SIZE: Optional. The number of results to return per
page. The maximum is 500. If the value is set to 0 or a negative value, an
appropriate default is selected. A nextPageToken is returned to retrieve
subsequent results.
Command examples
Run one of the following commands to get the names and asset types of the first two
Compute Engine instances in the my-project project, and export the results to the
my-table BigQuery table in the my-project project, overwriting
the entire table if it already exists.
[[["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 2026-06-10 UTC."],[],[]]