Skip to content

list_anomalies

list_anomalies(
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    time_range: Optional[IntelligenceTimeRange] = None,
    services: Optional[IntelligenceServiceNameList] = None,
    signal_types: Optional[AnomalySignalTypeList] = None,
    max_results: Optional[int] = None,
    next_token: Optional[PaginationToken] = None,
    severity: Optional[Severity] = None,
    source_account_id: Optional[SourceAccountIdList] = None,
    anomaly_ids: Optional[AnomalyIdList] = None,
) -> ListAnomaliesOutput

This operation is part of Observations, which is in preview release for Amazon CloudWatch Omni and is subject to change. Retrieves the anomalies matching the given filters.

Parameters:

  • time_range (Optional[IntelligenceTimeRange], default: None ) –

    Time window to scope the anomaly search.

  • services (Optional[IntelligenceServiceNameList], default: None ) –

    Filter by service names.

  • signal_types (Optional[AnomalySignalTypeList], default: None ) –

    Filter by signal types (e.g. logs, metrics, traces).

  • max_results (Optional[int], default: None ) –

    Maximum number of anomalies to return per page.

  • next_token (Optional[PaginationToken], default: None ) –

    Pagination token from a previous response.

  • severity (Optional[Severity], default: None ) –

    Filter by severity level. Anomaly severities are lowercase, so send "high", not "HIGH". One level only; there is no severity list and no minimum-severity filter.

  • source_account_id (Optional[SourceAccountIdList], default: None ) –

    Filter by the accounts that produced the signal.

  • anomaly_ids (Optional[AnomalyIdList], default: None ) –

    Optional batch-get filter. When set, anomalies are fetched by ID under the caller's account. Pagination still applies: maxResults bounds the returned anomalies per page; nextToken cursors through the input ID list. An ID that does not exist, or that the caller is not permitted to read, is omitted from items; compare the IDs you requested against the IDs returned across all pages to find them. anomalyIds is mutually exclusive with the other filters (timeRange, services, signalTypes, severity, sourceAccountId) — passing any of them alongside anomalyIds returns a ValidationException. Use a follow-up ListAnomalies call without anomalyIds for filtered queries.

Raises:

Examples:

List high-severity log anomalies for a service The following example lists the high-severity anomalies detected in the logs of one service over a one-hour window. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> client.list_anomalies(time_range={'start': '2026-09-16T00:00:00Z', 'end': '2026-09-16T01:00:00Z'}, services=['checkout-service'], signal_types=['logs'], severity='high', max_results=25)
Retrieve anomalies by ID
The following example retrieves two anomalies by their IDs, for example the anomalies an observation correlates. An ID that does not exist or that the caller cannot read is left out of the response. Payloads are shown as JSON; on the wire they are CBOR-encoded.
>>> client.list_anomalies(anomaly_ids=['3f6c1a4b8e0d2f5a7c9e1b3d5f7a9c0e2b4d6f8a0c2e4a6b8d0f2a4c6e8b0d2f', '7b2e4d6f8a0c1e3a5c7e9b1d3f5a7c9e0b2d4f6a8c0e2a4c6e8b0d2f4a6c8e0b'])
Read what accounted for a trace anomaly
The following example lists trace anomalies for a service. Each occurrence states what it measured and what accounted for the anomalous excess. The error rate carries no statistic because nothing aggregated it in CloudWatch's sense — it is a ratio the detector derived from counts. The shares have different bases and must not be summed across dimensions: a tool share is a share of the anomalous excess, while an error-class share is a share of the total failures. Payloads are shown as JSON; on the wire they are CBOR-encoded.
>>> client.list_anomalies(time_range={'start': '2026-09-16T00:00:00Z', 'end': '2026-09-16T01:00:00Z'}, services=['payments-service'], signal_types=['traces'], max_results=25)
Read a metric anomaly, including one that measures no figure
The following example lists metric anomalies. The first states the figure it compared, in the unit CloudWatch published the metric as; a metric occurrence carries no quantity, because the anomaly already names the metric. The second is a presence anomaly: it measures nothing, so it carries no measurement at all, and what it found is in signalDetails instead. Both still state the window their findings cover. Payloads are shown as JSON; on the wire they are CBOR-encoded.
>>> client.list_anomalies(time_range={'start': '2026-09-16T00:00:00Z', 'end': '2026-09-16T01:00:00Z'}, signal_types=['metrics'], max_results=25)
Source code in docs_src/capo_cloudwatchomni/_services/cloud_watch_omni.py
def list_anomalies(
    self,
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    time_range: Optional[
        "capo_cloudwatchomni.types.intelligence_time_range.IntelligenceTimeRange"
    ] = None,
    services: Optional[
        "capo_cloudwatchomni.types.intelligence_service_name_list.IntelligenceServiceNameList"
    ] = None,
    signal_types: Optional[
        "capo_cloudwatchomni.types.anomaly_signal_type_list.AnomalySignalTypeList"
    ] = None,
    max_results: Optional[int] = None,
    next_token: Optional[
        "capo_cloudwatchomni.types.pagination_token.PaginationToken"
    ] = None,
    severity: Optional["capo_cloudwatchomni.types.severity.Severity"] = None,
    source_account_id: Optional[
        "capo_cloudwatchomni.types.source_account_id_list.SourceAccountIdList"
    ] = None,
    anomaly_ids: Optional[
        "capo_cloudwatchomni.types.anomaly_id_list.AnomalyIdList"
    ] = None,
) -> "capo_cloudwatchomni.types.list_anomalies_output.ListAnomaliesOutput":
    """This operation is part of Observations, which is in preview release for Amazon CloudWatch Omni and is subject to change. Retrieves the anomalies matching the given filters.

    Args:
        time_range: Time window to scope the anomaly search.
        services: Filter by service names.
        signal_types: Filter by signal types (e.g. logs, metrics, traces).
        max_results: Maximum number of anomalies to return per page.
        next_token: Pagination token from a previous response.
        severity: Filter by severity level. Anomaly severities are lowercase, so send "high", not "HIGH". One level only; there is no severity list and no minimum-severity filter.
        source_account_id: Filter by the accounts that produced the signal.
        anomaly_ids: Optional batch-get filter. When set, anomalies are fetched by ID under the caller's account. Pagination still applies: maxResults bounds the returned anomalies per page; nextToken cursors through the input ID list. An ID that does not exist, or that the caller is not permitted to read, is omitted from items; compare the IDs you requested against the IDs returned across all pages to find them. anomalyIds is mutually exclusive with the other filters (timeRange, services, signalTypes, severity, sourceAccountId) — passing any of them alongside anomalyIds returns a ValidationException. Use a follow-up ListAnomalies call without anomalyIds for filtered queries.

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        List high-severity log anomalies for a service
        The following example lists the high-severity anomalies detected in the logs of one service over a one-hour window. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.list_anomalies(time_range={'start': '2026-09-16T00:00:00Z', 'end': '2026-09-16T01:00:00Z'}, services=['checkout-service'], signal_types=['logs'], severity='high', max_results=25)
        Retrieve anomalies by ID
        The following example retrieves two anomalies by their IDs, for example the anomalies an observation correlates. An ID that does not exist or that the caller cannot read is left out of the response. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.list_anomalies(anomaly_ids=['3f6c1a4b8e0d2f5a7c9e1b3d5f7a9c0e2b4d6f8a0c2e4a6b8d0f2a4c6e8b0d2f', '7b2e4d6f8a0c1e3a5c7e9b1d3f5a7c9e0b2d4f6a8c0e2a4c6e8b0d2f4a6c8e0b'])
        Read what accounted for a trace anomaly
        The following example lists trace anomalies for a service. Each occurrence states what it measured and what accounted for the anomalous excess. The error rate carries no statistic because nothing aggregated it in CloudWatch's sense — it is a ratio the detector derived from counts. The shares have different bases and must not be summed across dimensions: a tool share is a share of the anomalous excess, while an error-class share is a share of the total failures. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.list_anomalies(time_range={'start': '2026-09-16T00:00:00Z', 'end': '2026-09-16T01:00:00Z'}, services=['payments-service'], signal_types=['traces'], max_results=25)
        Read a metric anomaly, including one that measures no figure
        The following example lists metric anomalies. The first states the figure it compared, in the unit CloudWatch published the metric as; a metric occurrence carries no quantity, because the anomaly already names the metric. The second is a presence anomaly: it measures nothing, so it carries no measurement at all, and what it found is in signalDetails instead. Both still state the window their findings cover. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.list_anomalies(time_range={'start': '2026-09-16T00:00:00Z', 'end': '2026-09-16T01:00:00Z'}, signal_types=['metrics'], max_results=25)
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatchomni.types.list_anomalies_input.ListAnomaliesInput]",
    ) -> OperationResponse[
        "capo_cloudwatchomni.types.list_anomalies_output.ListAnomaliesOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.list_anomalies

        output, http_response = (
            capo_cloudwatchomni._operations.cloud_watch_omni_frontend.list_anomalies.list_anomalies(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_cloudwatchomni.types.list_anomalies_output.ListAnomaliesOutput",
    ) -> dict[str, Any]:
        import capo_cloudwatchomni.types.list_anomalies_output

        return capo_cloudwatchomni.types.list_anomalies_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListAnomalies", redact_output=_redact_output),
    )
    input_: capo_cloudwatchomni.types.list_anomalies_input.ListAnomaliesInput = {}
    if time_range is not None:
        input_["time_range"] = time_range
    if services is not None:
        input_["services"] = services
    if signal_types is not None:
        input_["signal_types"] = signal_types
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if severity is not None:
        input_["severity"] = severity
    if source_account_id is not None:
        input_["source_account_id"] = source_account_id
    if anomaly_ids is not None:
        input_["anomaly_ids"] = anomaly_ids

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