All Products
Search
Document Center

Object Storage Service:access-monitor

Last Updated:Apr 01, 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.

  • This topic provides sample command lines that are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil command reference.

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

Configure access tracking

  • Command syntax

    ./ossutil64 access-monitor --method put oss://bucketname/ local_xml_file

    The following table describes the parameters in the preceding command.

    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. The following sample code provides an example on how to configure access tracking for a bucket named examplebucket:

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

      The following output is returned:

      0.299514(s) elapsed

Query access tracking configurations

  • Command syntax

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

    The following table describes the parameters in the preceding command.

    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:

      ./ossutil64 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:

      ./ossutil64 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 Configure lifecycle rules.