Skip to content

create_anomaly_detector

create_anomaly_detector(
    workspace_id: WorkspaceId,
    alias: AnomalyDetectorAlias,
    configuration: AnomalyDetectorConfiguration,
    *,
    config_overrides: Optional[ampClientConfig] = None,
    evaluation_interval_in_seconds: Optional[AnomalyDetectorEvaluationInterval] = None,
    missing_data_action: Optional[AnomalyDetectorMissingDataAction] = None,
    labels: Optional[PrometheusMetricLabelMap] = None,
    client_token: Optional[IdempotencyToken] = None,
    tags: Optional[TagMap] = None,
) -> CreateAnomalyDetectorResponse

Creates an anomaly detector within a workspace using the Random Cut Forest algorithm for time-series analysis. The anomaly detector analyzes Amazon Managed Service for Prometheus metrics to identify unusual patterns and behaviors.

Parameters:

  • workspace_id (WorkspaceId) –

    The identifier of the workspace where the anomaly detector will be created.

  • alias (AnomalyDetectorAlias) –

    A user-friendly name for the anomaly detector.

  • evaluation_interval_in_seconds (Optional[AnomalyDetectorEvaluationInterval], default: None ) –

    The frequency, in seconds, at which the anomaly detector evaluates metrics. The default value is 60 seconds.

  • missing_data_action (Optional[AnomalyDetectorMissingDataAction], default: None ) –

    Specifies the action to take when data is missing during evaluation.

  • configuration (AnomalyDetectorConfiguration) –

    The algorithm configuration for the anomaly detector.

  • labels (Optional[PrometheusMetricLabelMap], default: None ) –

    The Amazon Managed Service for Prometheus metric labels to associate with the anomaly detector.

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

    A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

  • tags (Optional[TagMap], default: None ) –

    The metadata to apply to the anomaly detector to assist with categorization and organization.

Raises:

Source code in docs_src/capo_amp/_services/amp.py
def create_anomaly_detector(
    self,
    workspace_id: "capo_amp.types.workspace_id.WorkspaceId",
    alias: "capo_amp.types.anomaly_detector_alias.AnomalyDetectorAlias",
    configuration: "capo_amp.types.anomaly_detector_configuration.AnomalyDetectorConfiguration",
    *,
    config_overrides: Optional[ampClientConfig] = None,
    evaluation_interval_in_seconds: Optional[
        "capo_amp.types.anomaly_detector_evaluation_interval.AnomalyDetectorEvaluationInterval"
    ] = None,
    missing_data_action: Optional[
        "capo_amp.types.anomaly_detector_missing_data_action.AnomalyDetectorMissingDataAction"
    ] = None,
    labels: Optional[
        "capo_amp.types.prometheus_metric_label_map.PrometheusMetricLabelMap"
    ] = None,
    client_token: Optional[
        "capo_amp.types.idempotency_token.IdempotencyToken"
    ] = None,
    tags: Optional["capo_amp.types.tag_map.TagMap"] = None,
) -> (
    "capo_amp.types.create_anomaly_detector_response.CreateAnomalyDetectorResponse"
):
    """<p>Creates an anomaly detector within a workspace using the Random Cut Forest algorithm for time-series analysis. The anomaly detector analyzes Amazon Managed Service for Prometheus metrics to identify unusual patterns and behaviors.</p>

    Args:
        workspace_id: <p>The identifier of the workspace where the anomaly detector will be created.</p>
        alias: <p>A user-friendly name for the anomaly detector.</p>
        evaluation_interval_in_seconds: <p>The frequency, in seconds, at which the anomaly detector evaluates metrics. The default value is 60 seconds.</p>
        missing_data_action: <p>Specifies the action to take when data is missing during evaluation.</p>
        configuration: <p>The algorithm configuration for the anomaly detector.</p>
        labels: <p>The Amazon Managed Service for Prometheus metric labels to associate with the anomaly detector.</p>
        client_token: <p>A unique, case-sensitive identifier that you provide to ensure the idempotency of the request.</p>
        tags: <p>The metadata to apply to the anomaly detector to assist with categorization and organization.</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.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.
    """

    def _handler(
        req: "OperationRequest[capo_amp.types.create_anomaly_detector_request.CreateAnomalyDetectorRequest]",
    ) -> OperationResponse[
        "capo_amp.types.create_anomaly_detector_response.CreateAnomalyDetectorResponse"
    ]:
        import capo_amp._operations.amazon_prometheus_service.create_anomaly_detector

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateAnomalyDetector")
    )
    input_: capo_amp.types.create_anomaly_detector_request.CreateAnomalyDetectorRequest = {
        "workspace_id": workspace_id,
        "alias": alias,
        "configuration": configuration,
    }
    if evaluation_interval_in_seconds is not None:
        input_["evaluation_interval_in_seconds"] = evaluation_interval_in_seconds
    if missing_data_action is not None:
        input_["missing_data_action"] = missing_data_action
    if labels is not None:
        input_["labels"] = labels
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if tags is not None:
        input_["tags"] = tags

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