Creates a resource metrics configuration for an Amazon Web Services resource. After you create a configuration, Amazon CloudWatch collects detailed metrics for that resource.
Each Amazon Web Services 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 Web Services 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.
Parameters:
-
resource_arn
(Optional[ResourceArn], default:
None
)
–
The Amazon Resource Name (ARN) of the Amazon Web Services resource to enable detailed monitoring for.
-
metric_selections
(Optional[ResourceMetricSelectionList], default:
None
)
–
Specifies which metrics Amazon CloudWatch collects for the resource. If you omit this parameter, Amazon CloudWatch collects all available detailed metrics for the resource.
Raises:
Source code in docs_src/capo_cloudwatch/_services/cloud_watch.py
| def create_resource_metrics_configuration(
self,
*,
config_overrides: Optional[CloudWatchClientConfig] = None,
resource_arn: Optional["capo_cloudwatch.types.resource_arn.ResourceArn"] = None,
metric_selections: Optional[
"capo_cloudwatch.types.resource_metric_selection_list.ResourceMetricSelectionList"
] = None,
) -> "capo_cloudwatch.types.create_resource_metrics_configuration_output.CreateResourceMetricsConfigurationOutput":
"""<p>Creates a resource metrics configuration for an Amazon Web Services resource. After you create a configuration, Amazon CloudWatch collects detailed metrics for that resource.</p> <p>Each Amazon Web Services resource can have only one resource metrics configuration. If a configuration already exists for the specified resource ARN, this operation returns a <code>ConflictException</code>. To modify an existing configuration, use <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_UpdateResourceMetricsConfiguration.html">UpdateResourceMetricsConfiguration</a>.</p> <p>If the Amazon Web Services resource that you specify in <code>ResourceArn</code> does not exist, this operation returns a <code>ResourceNotFoundException</code>. Verify that the resource ARN is correct and that the resource exists before you retry the request.</p> <p>To create a resource metrics configuration, you must have the <code>cloudwatch:CreateResourceMetricsConfiguration</code> permission. For information about scoping this permission to specific resources, see <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/iam-cw-condition-keys-resource-arn.html">Condition keys for resource metrics configuration access</a> in the <i>Amazon CloudWatch User Guide</i>.</p>
Args:
resource_arn: <p>The Amazon Resource Name (ARN) of the Amazon Web Services resource to enable detailed monitoring for.</p>
metric_selections: <p>Specifies which metrics Amazon CloudWatch collects for the resource. If you omit this parameter, Amazon CloudWatch collects all available detailed metrics for the resource.</p>
Raises:
capo_cloudwatch.errors.conflict_exception.ConflictException: <p>This operation attempted to create a resource that already exists.</p>
capo_cloudwatch.errors.resource_not_found_exception.ResourceNotFoundException: <p>The named resource does not exist.</p>
capo_cloudwatch.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cloudwatch.types.create_resource_metrics_configuration_input.CreateResourceMetricsConfigurationInput]",
) -> OperationResponse[
"capo_cloudwatch.types.create_resource_metrics_configuration_output.CreateResourceMetricsConfigurationOutput"
]:
import capo_cloudwatch._operations.granite_service_version20100801.create_resource_metrics_configuration
output, http_response = (
capo_cloudwatch._operations.granite_service_version20100801.create_resource_metrics_configuration.create_resource_metrics_configuration(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("CreateResourceMetricsConfiguration")
)
input_: capo_cloudwatch.types.create_resource_metrics_configuration_input.CreateResourceMetricsConfigurationInput = {}
if resource_arn is not None:
input_["resource_arn"] = resource_arn
if metric_selections is not None:
input_["metric_selections"] = metric_selections
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|