Skip to content

update_scraper

update_scraper(
    scraper_id: ScraperId,
    *,
    config_overrides: Optional[ampClientConfig] = None,
    alias: Optional[ScraperAlias] = None,
    scrape_configuration: Optional[ScrapeConfiguration] = None,
    destination: Optional[Destination] = None,
    role_configuration: Optional[RoleConfiguration] = None,
    client_token: Optional[IdempotencyToken] = None,
    exporters: Optional[ExporterList] = None,
) -> UpdateScraperResponse

Updates an existing scraper.

You can't use this function to update the source from which the scraper is collecting metrics. To change the source, delete the scraper and create a new one.

Parameters:

  • scraper_id (ScraperId) –

    The ID of the scraper to update.

  • alias (Optional[ScraperAlias], default: None ) –

    The new alias of the scraper.

  • scrape_configuration (Optional[ScrapeConfiguration], default: None ) –

    Contains the base-64 encoded YAML configuration for the scraper.

    For more information about configuring a scraper, see Using an Amazon Web Services managed collector in the Amazon Managed Service for Prometheus User Guide.

  • destination (Optional[Destination], default: None ) –

    The new destination where the scraper sends metrics. Valid destinations are Amazon Managed Service for Prometheus workspaces and CloudWatch datasets.

  • role_configuration (Optional[RoleConfiguration], default: None ) –

    Use this structure to enable cross-account access, so that you can use a target account to access Prometheus metrics from source accounts.

  • client_token (Optional[IdempotencyToken], default: None ) –

    A unique identifier that you can provide to ensure the idempotency of the request. Case-sensitive.

  • exporters (Optional[ExporterList], default: None ) –

    The exporter configurations for the scraper. You can configure at most one Amazon OpenSearch Service domain. If you don't specify a value, the existing exporter configuration remains unchanged.

Raises:

Examples:

UpdateScraper with all optional parameters

>>> client.update_scraper(scraper_id='scraper-123', alias='alias-update', scrape_configuration={'configurationBlob': 'blob-update'}, destination={'ampConfiguration': {'workspaceArn': 'arn:aws:aps:us-west-2:123456789012:workspace/ws-ogh2u499-ce12-hg89-v6c7-123412341234-update'}}, client_token='token')
Source code in docs_src/capo_amp/_services/amp.py
def update_scraper(
    self,
    scraper_id: "capo_amp.types.scraper_id.ScraperId",
    *,
    config_overrides: Optional[ampClientConfig] = None,
    alias: Optional["capo_amp.types.scraper_alias.ScraperAlias"] = None,
    scrape_configuration: Optional[
        "capo_amp.types.scrape_configuration.ScrapeConfiguration"
    ] = None,
    destination: Optional["capo_amp.types.destination.Destination"] = None,
    role_configuration: Optional[
        "capo_amp.types.role_configuration.RoleConfiguration"
    ] = None,
    client_token: Optional[
        "capo_amp.types.idempotency_token.IdempotencyToken"
    ] = None,
    exporters: Optional["capo_amp.types.exporter_list.ExporterList"] = None,
) -> "capo_amp.types.update_scraper_response.UpdateScraperResponse":
    """<p>Updates an existing scraper.</p> <p>You can't use this function to update the source from which the scraper is collecting metrics. To change the source, delete the scraper and create a new one.</p>

    Args:
        scraper_id: <p>The ID of the scraper to update.</p>
        alias: <p>The new alias of the scraper.</p>
        scrape_configuration: <p>Contains the base-64 encoded YAML configuration for the scraper.</p> <note> <p>For more information about configuring a scraper, see <a href="https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-collector-how-to.html">Using an Amazon Web Services managed collector</a> in the <i>Amazon Managed Service for Prometheus User Guide</i>.</p> </note>
        destination: <p>The new destination where the scraper sends metrics. Valid destinations are Amazon Managed Service for Prometheus workspaces and CloudWatch datasets.</p>
        role_configuration: <p>Use this structure to enable cross-account access, so that you can use a target account to access Prometheus metrics from source accounts.</p>
        client_token: <p>A unique identifier that you can provide to ensure the idempotency of the request. Case-sensitive.</p>
        exporters: <p>The exporter configurations for the scraper. You can configure at most one Amazon OpenSearch Service domain. If you don't specify a value, the existing exporter configuration remains unchanged.</p>

    Raises:
        capo_amp.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_amp.errors.conflict_exception.ConflictException: <p>The request would cause an inconsistent state.</p>
        capo_amp.errors.internal_server_exception.InternalServerException: <p>An unexpected error occurred during the processing of the request.</p>
        capo_amp.errors.resource_not_found_exception.ResourceNotFoundException: <p>The request references a resources that doesn't exist.</p>
        capo_amp.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>Completing the request would cause a service quota to be exceeded.</p>
        capo_amp.errors.throttling_exception.ThrottlingException: <p>The request was denied due to request throttling.</p>
        capo_amp.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by an Amazon Web Services service.</p>
        capo_amp.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        UpdateScraper with all optional parameters

        >>> client.update_scraper(scraper_id='scraper-123', alias='alias-update', scrape_configuration={'configurationBlob': 'blob-update'}, destination={'ampConfiguration': {'workspaceArn': 'arn:aws:aps:us-west-2:123456789012:workspace/ws-ogh2u499-ce12-hg89-v6c7-123412341234-update'}}, client_token='token')
    """

    def _handler(
        req: "OperationRequest[capo_amp.types.update_scraper_request.UpdateScraperRequest]",
    ) -> OperationResponse[
        "capo_amp.types.update_scraper_response.UpdateScraperResponse"
    ]:
        import capo_amp._operations.amazon_prometheus_service.update_scraper

        output, http_response = (
            capo_amp._operations.amazon_prometheus_service.update_scraper.update_scraper(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("UpdateScraper")
    )
    input_: capo_amp.types.update_scraper_request.UpdateScraperRequest = {
        "scraper_id": scraper_id
    }
    if alias is not None:
        input_["alias"] = alias
    if scrape_configuration is not None:
        input_["scrape_configuration"] = scrape_configuration
    if destination is not None:
        input_["destination"] = destination
    if role_configuration is not None:
        input_["role_configuration"] = role_configuration
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if exporters is not None:
        input_["exporters"] = exporters

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output