Skip to content

update_resource_metrics_configuration async

update_resource_metrics_configuration(
    *,
    config_overrides: Optional[AsyncCloudWatchClientConfig] = None,
    resource_arn: Optional[ResourceArn] = None,
    metric_selections: Optional[ResourceMetricSelectionList] = None,
) -> UpdateResourceMetricsConfigurationOutput

Updates the resource metrics configuration for an Amazon Web Services resource. The MetricSelections value that you provide replaces any existing metric selections for the resource; it is not merged with them.

If you omit MetricSelections, Amazon CloudWatch removes any existing metric selection filter and collects all available detailed metrics for the resource.

This operation returns a ResourceNotFoundException if no resource metrics configuration exists for the specified resource ARN. To create a configuration, use CreateResourceMetricsConfiguration.

To update a resource metrics configuration, you must have the cloudwatch:UpdateResourceMetricsConfiguration 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 update the resource metrics configuration for.

  • metric_selections (Optional[ResourceMetricSelectionList], default: None ) –

    Specifies which metrics Amazon CloudWatch collects for the resource. The selections that you provide completely replace any existing metric selections.

    If you omit this parameter, Amazon CloudWatch removes any existing metric selection filter and collects all available detailed metrics for the resource.

Raises:

Source code in docs_src/capo_cloudwatch/_services/async_cloud_watch.py
async def update_resource_metrics_configuration(
    self,
    *,
    config_overrides: Optional[AsyncCloudWatchClientConfig] = 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.update_resource_metrics_configuration_output.UpdateResourceMetricsConfigurationOutput":
    """<p>Updates the resource metrics configuration for an Amazon Web Services resource. The <code>MetricSelections</code> value that you provide replaces any existing metric selections for the resource; it is not merged with them.</p> <p>If you omit <code>MetricSelections</code>, Amazon CloudWatch removes any existing metric selection filter and collects all available detailed metrics for the resource.</p> <p>This operation returns a <code>ResourceNotFoundException</code> if no resource metrics configuration exists for the specified resource ARN. To create a configuration, use <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_CreateResourceMetricsConfiguration.html">CreateResourceMetricsConfiguration</a>.</p> <p>To update a resource metrics configuration, you must have the <code>cloudwatch:UpdateResourceMetricsConfiguration</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 update the resource metrics configuration for.</p>
        metric_selections: <p>Specifies which metrics Amazon CloudWatch collects for the resource. The selections that you provide completely replace any existing metric selections.</p> <p>If you omit this parameter, Amazon CloudWatch removes any existing metric selection filter and collects all available detailed metrics for the resource.</p>

    Raises:
        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.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatch.types.update_resource_metrics_configuration_input.UpdateResourceMetricsConfigurationInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatch.types.update_resource_metrics_configuration_output.UpdateResourceMetricsConfigurationOutput"
    ]:
        import capo_cloudwatch._operations.granite_service_version20100801.update_resource_metrics_configuration

        (
            output,
            http_response,
        ) = await capo_cloudwatch._operations.granite_service_version20100801.update_resource_metrics_configuration.async_update_resource_metrics_configuration(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateResourceMetricsConfiguration")
    )
    input_: capo_cloudwatch.types.update_resource_metrics_configuration_input.UpdateResourceMetricsConfigurationInput = {}
    if resource_arn is not None:
        input_["resource_arn"] = resource_arn
    if metric_selections is not None:
        input_["metric_selections"] = metric_selections

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output