CreateResourceMetricsConfiguration
Creates a resource metrics configuration for an Amazon resource. After you create a configuration, Amazon CloudWatch collects detailed metrics for that resource.
Each Amazon resource can have only one resource metrics configuration. If a
configuration already exists for the specified resource ARN, this operation returns a
ConflictException. To modify an existing configuration, use UpdateResourceMetricsConfiguration.
If the Amazon resource that you specify in ResourceArn does
not exist, this operation returns a ResourceNotFoundException. Verify that
the resource ARN is correct and that the resource exists before you retry the
request.
To create a resource metrics configuration, you must have the
cloudwatch:CreateResourceMetricsConfiguration permission. For information about scoping
this permission to specific resources, see Condition keys for resource metrics configuration access in the
Amazon CloudWatch User Guide.
Request Syntax
{
"MetricSelections": [
{
"IncludeMetrics": [ "string" ]
}
],
"ResourceArn": "string"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- MetricSelections
-
Specifies which metrics Amazon CloudWatch collects for the resource. If you omit this parameter, Amazon CloudWatch collects all available detailed metrics for the resource.
Type: Array of ResourceMetricSelection objects
Array Members: Fixed number of 1 item.
Required: No
- ResourceArn
-
The Amazon Resource Name (ARN) of the Amazon resource to enable detailed monitoring for.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
Pattern:
arn:[a-zA-Z0-9-]+:[a-zA-Z0-9-]+:[a-zA-Z0-9-]*:\d{12}:.+Required: Yes
Response Syntax
{
"ResourceMetricsConfiguration": {
"CreatedAt": number,
"MetricSelections": [
{
"IncludeMetrics": [ "string" ]
}
],
"ResourceArn": "string",
"UpdatedAt": number
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- ResourceMetricsConfiguration
-
The resource metrics configuration that was created by this operation.
Type: ResourceMetricsConfiguration object
Errors
For information about the errors that are common to all actions, see Common Error Types.
- ConflictException
-
This operation attempted to create a resource that already exists.
HTTP Status Code: 409
- ResourceNotFoundException
-
The named resource does not exist.
HTTP Status Code: 404
See Also
For more information about using this API in one of the language-specific Amazon SDKs, see the following: