All Products
Search
Document Center

Object Storage Service:PutBucketAccessMonitor

Last Updated:Apr 29, 2024

Enables or disables access tracking for a bucket. If access tracking is enabled for a bucket, OSS records the last access time of objects in the bucket. In this case, you can configure lifecycle rules based on last access time to identify hot and cold data based on data access patterns and move cold data to a more cost-effective storage class.

Usage notes

To enable or disable access tracking for a bucket, you must have the oss:PutBucketAccessMonitor permission. For more information, see Attach a custom policy to a RAM user.

Request syntax

PUT /?accessmonitor HTTP/1.1
Host: BucketName.oss.aliyuncs.com
Date: GMT Date
Authorization: SignatureValue 
<?xml version="1.0" encoding="UTF-8"?>
<AccessMonitorConfiguration>
  <Status>Enabled</Status>
</AccessMonitorConfiguration>

Request headers

This request contains only common request headers. For more information, see Common HTTP headers.

Request elements

Element

Type

Required

Example

Description

AccessMonitorConfiguration

Container

Yes

N/A

The access tracking configurations of the bucket.

Child nodes: Status

Status

String

Yes

Enabled

Specifies whether to enable access tracking for the bucket. Valid values:

  • Enabled: enables access tracking.

    OSS initially uses the time when access tracking is enabled as the last access time of objects in the bucket and updates the last access time of an object if the object is accessed.

    The last access time of an object is updated asynchronously. If an object is accessed several times within a period of 24 hours, only the first access operation on the object within the period updates the last access time. You can specify a lifecycle rule based on last access time for the bucket.

  • Disabled: disables access tracking.

    Access tracking can be disabled only if the bucket does not have a lifecycle rule that is based on last access time.

Parent nodes: AccessMonitorConfiguration

Response headers

This request contains only common response headers. For more information, see Common HTTP headers.

Examples

Sample request

PUT /?accessmonitor HTTP/1.1
Host: oss-example.oss.aliyuncs.com
Date: Mon, 26 Jul 2021 13:08:38 GMT
Authorization: OSS qn6q**************:77Dv**************** 
<?xml version="1.0" encoding="UTF-8"?>
<AccessMonitorConfiguration>
  <Status>Enabled</Status>
</AccessMonitorConfiguration>

Sample response

HTTP/1.1 200 OK
x-oss-request-id: 5C1B138A109F4E405B2D****
Date: Mon, 26 Jul 2021 13:08:38 GMT
Content-Length: 0
Connection: keep-alive
Server: AliyunOSS

References

  • For more information about lifecycle rules based on last access time, see Lifecycle rules based on last access time.

  • After access tracking is enabled, you can call the PutBucketLifecycle operation to configure a lifecycle rule based on last access time. For more information, see PutBucketLifecycle.

Error codes

Error code

HTTP status code

Description

MalformedXML

400

The access tracking configuration is invalid.

AccessMonitorDisableNotAllowed

400

The access tracking status cannot be set to Disabled because the bucket has a lifecycle rule based on last access time.

AccessDenied

403

You are not authorized to access the bucket.

NoSuchBucket

404

The bucket does not exist.