Skip to main content

buckets

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

Overview

Namebuckets
TypeResource
Idgoogle.logging.buckets

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput only. The resource name of the bucket.For example:projects/my-project/locations/global/buckets/my-bucketFor a list of supported locations, see Supported Regions (https://cloud.google.com/logging/docs/region-support)For the location of global it is unspecified where log entries are actually stored.After a bucket has been created, the location cannot be changed.
analyticsEnabledbooleanOptional. Whether log analytics is enabled for this bucket.Once enabled, log analytics features cannot be disabled.
cmekSettingsobjectOptional. The CMEK settings of the log bucket. If present, new log entries written to this log bucket are encrypted using the CMEK key provided in this configuration. If a log bucket has CMEK settings, the CMEK settings cannot be disabled later by updating the log bucket. Changing the KMS key is allowed. (id: CmekSettings)
createTimestring (google-datetime)Output only. The creation timestamp of the bucket. This is not set for any of the default buckets.
descriptionstringOptional. Describes this bucket.
indexConfigsarrayOptional. A list of indexed fields and related configuration data.
lifecycleStatestringOutput only. The bucket lifecycle state.
lockedbooleanOptional. Whether the bucket is locked.The retention period on a locked bucket cannot be changed. Locked buckets may only be deleted if they are empty.
restrictedFieldsarrayOptional. Log entry field paths that are denied access in this bucket.The following fields and their children are eligible: textPayload, jsonPayload, protoPayload, httpRequest, labels, sourceLocation.Restricting a repeated field will restrict all values. Adding a parent will block all child fields. (e.g. foo.bar will block foo.bar.baz)
retentionDaysinteger (int32)Optional. Logs will be retained by default for this amount of time, after which they will automatically be deleted. The minimum retention period is 1 day. If this value is set to zero at bucket creation time, the default time of 30 days will be used.
updateTimestring (google-datetime)Output only. The last update timestamp of the bucket.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
projects_locations_buckets_getselectprojectsId, locationsId, bucketsIdGets a log bucket.
organizations_locations_buckets_getselectorganizationsId, locationsId, bucketsIdGets a log bucket.
folders_locations_buckets_getselectfoldersId, locationsId, bucketsIdGets a log bucket.
billing_accounts_locations_buckets_getselectbillingAccountsId, locationsId, bucketsIdGets a log bucket.
locations_buckets_listselectparentType, parentpageToken, pageSizeLists log buckets.
projects_locations_buckets_listselectprojectsId, locationsIdpageToken, pageSizeLists log buckets.
organizations_locations_buckets_listselectorganizationsId, locationsIdpageToken, pageSizeLists log buckets.
folders_locations_buckets_listselectfoldersId, locationsIdpageToken, pageSizeLists log buckets.
billing_accounts_locations_buckets_listselectbillingAccountsId, locationsIdpageToken, pageSizeLists log buckets.
locations_buckets_createinsertparentType, parentbucketIdCreates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.
projects_locations_buckets_createinsertprojectsId, locationsIdbucketIdCreates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.
organizations_locations_buckets_createinsertorganizationsId, locationsIdbucketIdCreates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.
folders_locations_buckets_createinsertfoldersId, locationsIdbucketIdCreates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.
billing_accounts_locations_buckets_createinsertbillingAccountsId, locationsIdbucketIdCreates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.
projects_locations_buckets_patchupdateprojectsId, locationsId, bucketsIdupdateMaskUpdates a log bucket.If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.After a bucket has been created, the bucket's location cannot be changed.
organizations_locations_buckets_patchupdateorganizationsId, locationsId, bucketsIdupdateMaskUpdates a log bucket.If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.After a bucket has been created, the bucket's location cannot be changed.
folders_locations_buckets_patchupdatefoldersId, locationsId, bucketsIdupdateMaskUpdates a log bucket.If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.After a bucket has been created, the bucket's location cannot be changed.
billing_accounts_locations_buckets_patchupdatebillingAccountsId, locationsId, bucketsIdupdateMaskUpdates a log bucket.If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.After a bucket has been created, the bucket's location cannot be changed.
projects_locations_buckets_deletedeleteprojectsId, locationsId, bucketsIdDeletes a log bucket.Changes the bucket's lifecycle_state to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all log entries in the bucket will be permanently deleted.
organizations_locations_buckets_deletedeleteorganizationsId, locationsId, bucketsIdDeletes a log bucket.Changes the bucket's lifecycle_state to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all log entries in the bucket will be permanently deleted.
folders_locations_buckets_deletedeletefoldersId, locationsId, bucketsIdDeletes a log bucket.Changes the bucket's lifecycle_state to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all log entries in the bucket will be permanently deleted.
billing_accounts_locations_buckets_deletedeletebillingAccountsId, locationsId, bucketsIdDeletes a log bucket.Changes the bucket's lifecycle_state to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all log entries in the bucket will be permanently deleted.
locations_buckets_undeleteexecnameUndeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.
projects_locations_buckets_undeleteexecprojectsId, locationsId, bucketsIdUndeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.
organizations_locations_buckets_undeleteexecorganizationsId, locationsId, bucketsIdUndeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.
folders_locations_buckets_undeleteexecfoldersId, locationsId, bucketsIdUndeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.
billing_accounts_locations_buckets_undeleteexecbillingAccountsId, locationsId, bucketsIdUndeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.

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
bucketsIdstring
foldersIdstring
locationsIdstring
namestring
organizationsIdstring
parentstring
parentTypestring
projectsIdstring
bucketIdstring
pageSizeinteger (int32)
pageTokenstring
updateMaskstring (google-fieldmask)

SELECT examples

Gets a log bucket.

SELECT
name,
analyticsEnabled,
cmekSettings,
createTime,
description,
indexConfigs,
lifecycleState,
locked,
restrictedFields,
retentionDays,
updateTime
FROM google.logging.buckets
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND bucketsId = '{{ bucketsId }}' -- required;

INSERT examples

Creates a log bucket that can be used to store log entries. After a bucket has been created, the bucket's location cannot be changed.

INSERT INTO google.logging.buckets (
data__description,
data__retentionDays,
data__locked,
data__analyticsEnabled,
data__restrictedFields,
data__indexConfigs,
data__cmekSettings,
parentType,
parent,
bucketId
)
SELECT
'{{ description }}',
{{ retentionDays }},
{{ locked }},
{{ analyticsEnabled }},
'{{ restrictedFields }}',
'{{ indexConfigs }}',
'{{ cmekSettings }}',
'{{ parentType }}',
'{{ parent }}',
'{{ bucketId }}'
RETURNING
name,
analyticsEnabled,
cmekSettings,
createTime,
description,
indexConfigs,
lifecycleState,
locked,
restrictedFields,
retentionDays,
updateTime
;

UPDATE examples

Updates a log bucket.If the bucket has a lifecycle_state of DELETE_REQUESTED, then FAILED_PRECONDITION will be returned.After a bucket has been created, the bucket's location cannot be changed.

UPDATE google.logging.buckets
SET
data__description = '{{ description }}',
data__retentionDays = {{ retentionDays }},
data__locked = {{ locked }},
data__analyticsEnabled = {{ analyticsEnabled }},
data__restrictedFields = '{{ restrictedFields }}',
data__indexConfigs = '{{ indexConfigs }}',
data__cmekSettings = '{{ cmekSettings }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND bucketsId = '{{ bucketsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
analyticsEnabled,
cmekSettings,
createTime,
description,
indexConfigs,
lifecycleState,
locked,
restrictedFields,
retentionDays,
updateTime;

DELETE examples

Deletes a log bucket.Changes the bucket's lifecycle_state to the DELETE_REQUESTED state. After 7 days, the bucket will be purged and all log entries in the bucket will be permanently deleted.

DELETE FROM google.logging.buckets
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND bucketsId = '{{ bucketsId }}' --required;

Lifecycle Methods

Undeletes a log bucket. A bucket that has been deleted can be undeleted within the grace period of 7 days.

EXEC google.logging.buckets.locations_buckets_undelete 
@name='{{ name }}' --required;