Menu
Amazon Simple Storage Service
API Reference (API Version 2006-03-01)

PUT Bucket metrics

Description

Sets or updates a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from the bucket. If you're updating an existing metrics configuration, note that this is a full replacement of the existing metrics configuration. If you don't include the elements you want to keep, they are erased.

To use this operation, you must have permissions to perform the s3:PutMetricsConfiguration action. The bucket owner has this permission by default. The bucket owner can grant this permission to others. For more information about permissions, see Permissions Related to Bucket Subresource Operations and Managing Access Permissions to Your Amazon S3 Resources in the Amazon Simple Storage Service Developer Guide.

For information about CloudWatch request metrics for Amazon S3, see Monitoring Metrics with Amazon CloudWatch in the Amazon Simple Storage Service Developer Guide.

Requests

Syntax

Copy
PUT /?metrics&id=id HTTP/1.1 HOST: BucketName.s3.amazonaws.com Content-Length: length Date: date Authorization: authorization string (see Authenticating Requests (AWS Signature Version 4)) Metrics configuration in the request body.

Request Parameters

This implementation of PUT uses the parameter in the following table.

Parameter Description Required
id

The ID used to identify the metrics configuration.

Yes

Request Headers

This implementation of the operation uses only request headers that are common to all operations. For more information, see Common Request Headers.

Request Elements

In the request, you must specify the metrics configuration in the request body, which is specified as XML. The Examples section shows an example of a metrics configuration.

The following table describes the XML elements in the metrics configuration:

Parameter Description Required
And

A conjunction (logical AND) of predicates, which is used in evaluating a metrics filter. The operator must have at least two predicates in any combination, and an object must match all of the predicates for the filter to apply.

Type: Container

Children: Prefix, Tag

Ancestor: Filter

No
Filter

Specifies a metrics configuration filter. The metrics configuration includes only objects that meet the filter's criteria. A filter must be a prefix, a tag, or a conjunction (And). There's a limit of 11 predicates for each filter, of which there can be one prefix and up to ten tags in a single filter.

Type: Container

Children: And

No
Id

The ID used to identify the metrics configuration.

Type: String

Ancestor: MetricsConfiguration

Yes
Key

The name of the tag.

Type: String

Ancestor: Tag

No
MetricsConfiguration

Specifies the metrics configuration for CloudWatch request metrics on this bucket.

Type: Container

Ancestor: None

Yes
Prefix

The prefix that an object must have to be included in the metrics results.

Type: String

Ancestor: And

No
Tag

A key-value name pair, used to organize objects by association.

Type: Container

Children: Key, Value,

Ancestor: And

No
Value

The value of the tag.

Type: String

Ancestor: Tag

No

Responses

Response Headers

The operation returns response headers that are common to most responses. For more information, see Common Response Headers.

Response Elements

This implementation of the operation does not return response elements.

Special Errors

This implementation of the operation does not return special errors. For general information about Amazon S3 errors and a list of error codes, see Error Responses.

Examples

First Sample Request

Put a metric configuration that enables metrics for an entire bucket.

Copy
PUT /?metrics&id=EntireBucket HTTP/1.1 Host: examplebucket.s3.amazonaws.com x-amz-date: Thu, 15 Nov 2016 00:17:21 GMT Authorization: signatureValue Content-Length: 159 <?xml version="1.0" encoding="UTF-8"?> <MetricsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>EntireBucket</Id> </MetricsConfiguration>

First Sample Response

Put a metric configuration that enables metrics for an entire bucket.

Copy
HTTP/1.1 204 No Content x-amz-id-2: ITnGT1y4REXAMPLEPi4hklTXouTf0hccUjo0iCPEXAMPLEutBj3M7fPGlWO2SEWp x-amz-request-id: 51991EXAMPLE5321 Date: Thu, 15 Nov 2016 00:17:22 GMT Server: AmazonS3

Second Sample Request

Put a metrics configuration that enables metrics for objects that start with a particular prefix and also have specific tags applied.

Copy
PUT /?metrics&id=ImportantBlueDocuments HTTP/1.1 Host: examplebucket.s3.amazonaws.com x-amz-date: Thu, 15 Nov 2016 00:17:29 GMT Authorization: signatureValue Content-Length: 480 <?xml version="1.0" encoding="UTF-8"?> <MetricsConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"> <Id>ImportantBlueDocuments</Id> <Filter> <And> <Prefix>documents/</Prefix> <Tag> <Key>priority</Key> <Value>high</Value> </Tag> <Tag> <Key>class</Key> <Value>blue</Value> </Tag> </And> </Filter> </MetricsConfiguration>

Second Sample Response

Put a metrics configuration that enables metrics for objects that start with a particular prefix and also have specific tags applied.

Copy
HTTP/1.1 204 No Content x-amz-id-2: ITnGT1y4REXAMPLEPi4hklTXouTf0hccUjo0iCPEXAMPLEutBj3M7fPGlWO2SEWp x-amz-request-id: 51991EXAMPLE5321 Date: Thu, 15 Nov 2016 00:17:29 GMT Server: AmazonS3