Skip to main content

saved_queries

Creates, updates, deletes, gets or lists a saved_queries resource.

Overview

Namesaved_queries
TypeResource
Idgoogle.logging.saved_queries

Fields

NameDatatypeDescription
namestringOutput only. Resource name of the saved query.In the format: "projects/[PROJECT_ID]/locations/[LOCATION_ID]/savedQueries/[QUERY_ID]" For a list of supported locations, see Supported Regions (https://cloud.google.com/logging/docs/region-support#bucket-regions)After the saved query is created, the location cannot be changed.If the user doesn't provide a QUERY_ID, the system will generate an alphanumeric ID.
descriptionstringOptional. A human readable description of the saved query.
createTimestringOutput only. The timestamp when the saved query was created.
displayNamestringRequired. The user specified title for the SavedQuery.
loggingQueryobjectDescribes a Cloud Logging query that can be run in Logs Explorer UI or via the logging API.In addition to the query itself, additional information may be stored to capture the display configuration and other UI state used in association with analysis of query results.
opsAnalyticsQueryobjectDescribes an analytics query that can be run in the Log Analytics page of Google Cloud console.Preview: This is a preview feature and may be subject to change before final release.
updateTimestringOutput only. The timestamp when the saved query was last updated.
visibilitystringRequired. The visibility status of this query, which determines its ownership.

Methods

NameAccessible byRequired ParamsDescription
billing_accounts_locations_saved_queries_getSELECTbillingAccountsId, locationsId, savedQueriesIdReturns all data associated with the requested query.
billing_accounts_locations_saved_queries_listSELECTbillingAccountsId, locationsIdLists the SavedQueries that were created by the user making the request.
folders_locations_saved_queries_getSELECTfoldersId, locationsId, savedQueriesIdReturns all data associated with the requested query.
folders_locations_saved_queries_listSELECTfoldersId, locationsIdLists the SavedQueries that were created by the user making the request.
organizations_locations_saved_queries_getSELECTlocationsId, organizationsId, savedQueriesIdReturns all data associated with the requested query.
organizations_locations_saved_queries_listSELECTlocationsId, organizationsIdLists the SavedQueries that were created by the user making the request.
projects_locations_saved_queries_getSELECTlocationsId, projectsId, savedQueriesIdReturns all data associated with the requested query.
projects_locations_saved_queries_listSELECTlocationsId, projectsIdLists the SavedQueries that were created by the user making the request.
billing_accounts_locations_saved_queries_createINSERTbillingAccountsId, locationsIdCreates a new SavedQuery for the user making the request.
folders_locations_saved_queries_createINSERTfoldersId, locationsIdCreates a new SavedQuery for the user making the request.
organizations_locations_saved_queries_createINSERTlocationsId, organizationsIdCreates a new SavedQuery for the user making the request.
projects_locations_saved_queries_createINSERTlocationsId, projectsIdCreates a new SavedQuery for the user making the request.
billing_accounts_locations_saved_queries_deleteDELETEbillingAccountsId, locationsId, savedQueriesIdDeletes an existing SavedQuery that was created by the user making the request.
folders_locations_saved_queries_deleteDELETEfoldersId, locationsId, savedQueriesIdDeletes an existing SavedQuery that was created by the user making the request.
organizations_locations_saved_queries_deleteDELETElocationsId, organizationsId, savedQueriesIdDeletes an existing SavedQuery that was created by the user making the request.
projects_locations_saved_queries_deleteDELETElocationsId, projectsId, savedQueriesIdDeletes an existing SavedQuery that was created by the user making the request.
billing_accounts_locations_saved_queries_patchUPDATEbillingAccountsId, locationsId, savedQueriesIdUpdates an existing SavedQuery.
folders_locations_saved_queries_patchUPDATEfoldersId, locationsId, savedQueriesIdUpdates an existing SavedQuery.
organizations_locations_saved_queries_patchUPDATElocationsId, organizationsId, savedQueriesIdUpdates an existing SavedQuery.
projects_locations_saved_queries_patchUPDATElocationsId, projectsId, savedQueriesIdUpdates an existing SavedQuery.

SELECT examples

Lists the SavedQueries that were created by the user making the request.

SELECT
name,
description,
createTime,
displayName,
loggingQuery,
opsAnalyticsQuery,
updateTime,
visibility
FROM google.logging.saved_queries
WHERE foldersId = '{{ foldersId }}'
AND locationsId = '{{ locationsId }}';

INSERT example

Use the following StackQL query and manifest file to create a new saved_queries resource.

/*+ create */
INSERT INTO google.logging.saved_queries (
foldersId,
locationsId,
displayName,
description,
loggingQuery,
opsAnalyticsQuery,
visibility
)
SELECT
'{{ foldersId }}',
'{{ locationsId }}',
'{{ displayName }}',
'{{ description }}',
'{{ loggingQuery }}',
'{{ opsAnalyticsQuery }}',
'{{ visibility }}'
;

UPDATE example

Updates a saved_queries resource.

/*+ update */
UPDATE google.logging.saved_queries
SET
displayName = '{{ displayName }}',
description = '{{ description }}',
loggingQuery = '{{ loggingQuery }}',
opsAnalyticsQuery = '{{ opsAnalyticsQuery }}',
visibility = '{{ visibility }}'
WHERE
foldersId = '{{ foldersId }}'
AND locationsId = '{{ locationsId }}'
AND savedQueriesId = '{{ savedQueriesId }}';

DELETE example

Deletes the specified saved_queries resource.

/*+ delete */
DELETE FROM google.logging.saved_queries
WHERE foldersId = '{{ foldersId }}'
AND locationsId = '{{ locationsId }}'
AND savedQueriesId = '{{ savedQueriesId }}';