All Products
Search
Document Center

Object Storage Service:access-monitor

Last Updated:Aug 19, 2024

You can configure lifecycle rules based on the last access time of objects to automatically monitor the access pattern of objects in a bucket, identify cold data, and then convert the storage class of the cold data. This helps reduce storage costs. Before you configure a lifecycle rule based on the last access time of objects in a bucket, you must run the access-monitor command to enable access tracking for the bucket.

Usage notes

  • To enable access tracking, you must have the oss:PutBucketAccessMonitor permission. To query the access tracking configurations of a bucket, you must have the oss:GetBucketAccessMonitor permission. For more information, see Attach a custom policy to a RAM user.

  • For ossutil 1.6.16 and later, you can directly use ossutil as the binary name in the command line. You do not need to update the binary name based on the operating system. For ossutil earlier than 1.6.16, you need to update the binary name based on the operating system. For more information, see ossutil command reference.

  • Only ossutil 1.7.15 and later support the access-monitor command.

Configure access tracking

  • Command syntax

    ossutil access-monitor --method put oss://bucketname/ local_xml_file

    The following table describes the preceding parameters.

    Parameter

    Description

    bucketname

    The name of the bucket for which you want to configure access tracking.

    local_xml_file

    The name of the local file that is used to configure access tracking. Example: config.xml.

  • Examples

    1. Enable or disable access tracking by using a local XML file.

      • Enable access tracking

        <?xml version="1.0" encoding="UTF-8"?>
        <AccessMonitorConfiguration>
            <Status>Enabled</Status>
        </AccessMonitorConfiguration>
      • Disable access tracking

        <?xml version="1.0" encoding="UTF-8"?>
        <AccessMonitorConfiguration>
            <Status>Disabled</Status>
        </AccessMonitorConfiguration>
    2. Configure access tracking for a bucket named examplebucket.

      ossutil access-monitor --method put oss://examplebucket/ config.xml

      The following output is returned:

      0.299514(s) elapsed

Query access tracking configurations

  • Command syntax

    ossutil access-monitor --method get oss://bucketname [local_xml_file]

    The following table describes the preceding parameters.

    Parameter

    Description

    bucketname

    The name of the bucket whose access tracking configurations you want to query.

    local_xml_file

    The name of the local file that is used to store access tracking configurations. Example: local.xml. If this parameter is not specified, the access tracking configurations are displayed.

  • Examples

    • The following sample code provides an example on how to query and display the access tracking configurations of a bucket named examplebucket:

      ossutil access-monitor --method get oss://examplebucket

      The following output is returned:

      <?xml version="1.0" encoding="UTF-8"?>
      <AccessMonitorConfiguration>
        <Status>Enabled</Status>
      </AccessMonitorConfiguration>
      
      0.154689(s) elapsed
    • The following sample code provides an example on how to query the access tracking configurations of a bucket named examplebucket and store the configurations in the local.xml file:

      ossutil access-monitor --method get oss://examplebucket/ local.xml

      The following output is returned:

      • The following result is displayed:

        0.214483(s) elapsed
      • The local.xml file contains the following content:

        <?xml version="1.0" encoding="UTF-8"?>
        <AccessMonitorConfiguration>
          <Status>Enabled</Status>
        </AccessMonitorConfiguration>

What to do next

After access tracking is enabled, you need to configure lifecycle rules based on the last access time of objects to convert the storage class of cold data. This reduces storage costs. For more information, see lifecycle.