gcloud alpha asset query Stay organized with collections Save and categorize content based on your preferences.
- NAME
- gcloud alpha asset query - query the Cloud assets
- SYNOPSIS
gcloud alpha asset query(--folder=FOLDER_ID|--organization=ORGANIZATION_ID|--project=PROJECT_ID)(--job-reference=JOB_REFERENCE|--statement=STATEMENT)[--page-size=PAGE_SIZE][--page-token=PAGE_TOKEN][--timeout=TIMEOUT][--snapshot-time=SNAPSHOT_TIME| [--start-time=START_TIME:--end-time=END_TIME]][--write-disposition=WRITE_DISPOSITION[--bigquery-table=BIGQUERY_TABLE:--bigquery-dataset=BIGQUERY_DATASET]][GCLOUD_WIDE_FLAG …]
- DESCRIPTION
(ALPHA)Issue an analytical query on Cloud assets using a BigQueryStandard SQL compatible statement.- EXAMPLES
- To count the number of compute instances, run:
gcloudalphaassetquery--project='test-project'--statement='SELECT * FROM compute_googleapis_com_Instance'To see the query result of the previous job, pass the job-reference from theprevious response:
gcloudalphaassetquery--project='test-project'--job-reference=<job-reference-from> - REQUIRED FLAGS
- Exactly one of these must be specified:
--folder=FOLDER_ID- The ID of the folder which is the root asset.
--organization=ORGANIZATION_ID- The ID of the organization which is the root asset.
--project=PROJECT_ID- The project which is the root asset.
The Google Cloud project ID to use for this invocation. If omitted, then thecurrent project is assumed; the current project can be listed using
gcloudconfig list --format='text(core.project)'and can be set usinggcloud config set project PROJECTID.--projectand its fallbackcore/projectproperty playtwo roles in the invocation. It specifies the project of the resource to operateon. It also specifies the project for API enablement check, quota, and billing.To specify a different project for quota and billing, use--billing-projectorbilling/quota_projectproperty.
- The query or job reference of the query request.
Exactly one of these must be specified:
--job-reference=JOB_REFERENCE- Reference to the query job, which is from the previous call.
--statement=STATEMENT- A BigQuery Standard SQL compatible statement. If the query execution finisheswithin timeout and there is no pagination, the full query results will bereturned. Otherwise, pass job_reference from previous call as
--job-referenceto obtain the full results.
- Exactly one of these must be specified:
- OPTIONAL FLAGS
--page-size=PAGE_SIZE- The maximum number of rows to return in the results. One page is also limited to10 MB.
--page-token=PAGE_TOKEN- A page token received from previous call.
--timeout=TIMEOUT- Maximum amount of time that the client will wait for the query to complete.
- Specifies what time period or point in time to query asset metadata at.
At most one of these can be specified:
--snapshot-time=SNAPSHOT_TIME- Timestamp to take a snapshot on assets. This can only be a current or past time.If not specified, the current time will be used. Due to delays in resource datacollection and indexing, there is a volatile window during which running thesame query at different times may return different results. See $gcloud topic datetimes forinformation on time formats.
- Specifies what time period or point in time to query asset metadata at.
--start-time=START_TIME- Start time of the time window (inclusive) for the asset history. Must be afterthe current time minus 35 days. See $gcloud topic datetimes forinformation on time formats.
This flag argument must be specified if any of the other arguments in this groupare specified.
--end-time=END_TIME- End time of the time window (exclusive) for the asset history. Defaults tocurrent time if not specified. See $gcloud topic datetimes forinformation on time formats.
- The BigQuery destination for query system.
--write-disposition=WRITE_DISPOSITION- Specifies the action that occurs if the destination table or partition alreadyexists.
WRITE_DISPOSITIONmust be one of:write-append- If the table or partition already exists, BigQuery appends the data to the tableor the latest partition.
write-empty- If the table already exists and contains data, an error is returned.
write-truncate- If the table or partition already exists, BigQuery overwrites the entire tableor all the partition's data.
- Table resource - The bigquery-table for the export. The arguments in this groupcan be used to specify the attributes of this resource. (NOTE) Some attributesare not given arguments in this group but can be set in other ways.
To set the
projectattribute:- provide the argument
--bigquery-tableon the command line with afully specified name; - provide the argument
--projecton the command line; - set the property
core/project.
--bigquery-table=BIGQUERY_TABLE- ID of the table or fully qualified identifier for the table.
To set the
tableattribute:- provide the argument
--bigquery-tableon the command line.
This flag argument must be specified if any of the other arguments in this groupare specified.
- provide the argument
--bigquery-dataset=BIGQUERY_DATASET- The id of the BigQuery dataset.
To set the
bigquery-datasetattribute:- provide the argument
--bigquery-tableon the command line with afully specified name; - provide the argument
--bigquery-dataseton the command line.
- provide the argument
- provide the argument
- GCLOUD WIDE FLAGS
- These flags are available to all commands:
--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.Run
$gcloud helpfor details. - NOTES
- This command is currently in alpha and might change without notice. If thiscommand fails with API permission errors despite specifying the correct project,you might be trying to access an API with an invitation-only early accessallowlist. These variants are also available:
gcloudassetquerygcloudbetaassetquery
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-05-07 UTC.