Try it now and let us know what you think. Switch to the new look >>
You can return to the original look by selecting English in the language selector above.
PUT Bucket metrics
Description
Sets or updates a metrics configuration for the CloudWatch request metrics (specified by the metrics configuration ID) from the bucket. You can have up to 1,000 metrics configurations per 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
PUT /?metrics&id=idHTTP/1.1 HOST:BucketName.s3.amazonaws.com Content-Length:lengthDate:dateAuthorization: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: Ancestor: |
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: |
No |
Id
|
The ID used to identify the metrics configuration. Type: String Ancestor: |
Yes |
Key
|
The name of the tag. Type: String Ancestor: |
No |
MetricsConfiguration |
Specifies the metrics configuration for CloudWatch request metrics on this bucket. Type: Container Ancestor: |
Yes |
Prefix
|
The prefix that an object must have to be included in the metrics results. Type: String Ancestor: |
No |
Tag
|
A key-value name pair, used to organize objects by association. Type: Container Children: Ancestor: |
No |
Value
|
The value of the tag. Type: String Ancestor: |
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
Amazon S3 checks the validity of the proposed MetricsConfiguration element and
verifies whether the proposed configuration is valid when you call the
PUT operation. The following table lists the errors and possible
causes.
| HTTP Error | Code | Cause |
|---|---|---|
HTTP 400 Bad Request |
TooManyConfigurations |
You are attempting to create a new configuration but have already reached the 1,000-configuration limit. |
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.
PUT /?metrics&id=EntireBucket HTTP/1.1 Host: examplebucket.s3.amazonaws.com x-amz-date: Thu, 15 Nov 2016 00:17:21 GMT Authorization:signatureValueContent-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.
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.
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.
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
Related Resources
-
Monitoring Metrics with Amazon CloudWatch in the Amazon Simple Storage Service Developer Guide.


