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

The following fields are returned by SELECT queries:

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://docs.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.
createTimestring (google-datetime)Output only. The timestamp when the saved query was created.
descriptionstringOptional. A human readable description of the saved query.
displayNamestringRequired. The user specified title for the SavedQuery.
loggingQueryobjectLogging query that can be executed in Logs Explorer or via Logging API. (id: LoggingQuery)
opsAnalyticsQueryobjectAnalytics query that can be executed in Log Analytics. (id: OpsAnalyticsQuery)
updateTimestring (google-datetime)Output only. The timestamp when the saved query was last updated.
visibilitystringRequired. The visibility status of this query, which determines its ownership. (VISIBILITY_UNSPECIFIED, PRIVATE, SHARED)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
billing_accounts_locations_saved_queries_getselectbillingAccountsId, locationsId, savedQueriesIdReturns all data associated with the requested query.
folders_locations_saved_queries_getselectfoldersId, locationsId, savedQueriesIdReturns all data associated with the requested query.
projects_locations_saved_queries_getselectprojectsId, locationsId, savedQueriesIdReturns all data associated with the requested query.
organizations_locations_saved_queries_getselectorganizationsId, locationsId, savedQueriesIdReturns all data associated with the requested query.
billing_accounts_locations_saved_queries_listselectbillingAccountsId, locationsIdfilter, pageToken, pageSizeLists the SavedQueries that were created by the user making the request.
folders_locations_saved_queries_listselectfoldersId, locationsIdfilter, pageToken, pageSizeLists the SavedQueries that were created by the user making the request.
projects_locations_saved_queries_listselectprojectsId, locationsIdpageToken, pageSize, filterLists the SavedQueries that were created by the user making the request.
organizations_locations_saved_queries_listselectorganizationsId, locationsIdpageToken, pageSize, filterLists the SavedQueries that were created by the user making the request.
billing_accounts_locations_saved_queries_createinsertbillingAccountsId, locationsIdsavedQueryIdCreates a new SavedQuery for the user making the request.
folders_locations_saved_queries_createinsertfoldersId, locationsIdsavedQueryIdCreates a new SavedQuery for the user making the request.
projects_locations_saved_queries_createinsertprojectsId, locationsIdsavedQueryIdCreates a new SavedQuery for the user making the request.
organizations_locations_saved_queries_createinsertorganizationsId, locationsIdsavedQueryIdCreates a new SavedQuery for the user making the request.
billing_accounts_locations_saved_queries_patchupdatebillingAccountsId, locationsId, savedQueriesIdupdateMaskUpdates an existing SavedQuery.
folders_locations_saved_queries_patchupdatefoldersId, locationsId, savedQueriesIdupdateMaskUpdates an existing SavedQuery.
projects_locations_saved_queries_patchupdateprojectsId, locationsId, savedQueriesIdupdateMaskUpdates an existing SavedQuery.
organizations_locations_saved_queries_patchupdateorganizationsId, locationsId, savedQueriesIdupdateMaskUpdates an existing SavedQuery.
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.
projects_locations_saved_queries_deletedeleteprojectsId, locationsId, savedQueriesIdDeletes an existing SavedQuery that was created by the user making the request.
organizations_locations_saved_queries_deletedeleteorganizationsId, locationsId, savedQueriesIdDeletes an existing SavedQuery that was created by the user making the request.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
billingAccountsIdstring
foldersIdstring
locationsIdstring
organizationsIdstring
projectsIdstring
savedQueriesIdstring
filterstring
pageSizeinteger (int32)
pageTokenstring
savedQueryIdstring
updateMaskstring (google-fieldmask)

SELECT examples

Returns all data associated with the requested query.

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

INSERT examples

Creates a new SavedQuery for the user making the request.

INSERT INTO google.logging.saved_queries (
data__visibility,
data__description,
data__opsAnalyticsQuery,
data__displayName,
data__loggingQuery,
billingAccountsId,
locationsId,
savedQueryId
)
SELECT
'{{ visibility }}',
'{{ description }}',
'{{ opsAnalyticsQuery }}',
'{{ displayName }}',
'{{ loggingQuery }}',
'{{ billingAccountsId }}',
'{{ locationsId }}',
'{{ savedQueryId }}'
RETURNING
name,
createTime,
description,
displayName,
loggingQuery,
opsAnalyticsQuery,
updateTime,
visibility
;

UPDATE examples

Updates an existing SavedQuery.

UPDATE google.logging.saved_queries
SET
data__visibility = '{{ visibility }}',
data__description = '{{ description }}',
data__opsAnalyticsQuery = '{{ opsAnalyticsQuery }}',
data__displayName = '{{ displayName }}',
data__loggingQuery = '{{ loggingQuery }}'
WHERE
billingAccountsId = '{{ billingAccountsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND savedQueriesId = '{{ savedQueriesId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
createTime,
description,
displayName,
loggingQuery,
opsAnalyticsQuery,
updateTime,
visibility;

DELETE examples

Deletes an existing SavedQuery that was created by the user making the request.

DELETE FROM google.logging.saved_queries
WHERE billingAccountsId = '{{ billingAccountsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND savedQueriesId = '{{ savedQueriesId }}' --required
;