Skip to content

list_observations

list_observations(
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    filters: Optional[ObservationFilters] = None,
    max_results: Optional[int] = None,
    next_token: Optional[PaginationToken] = None,
    observation_ids: Optional[ObservationIdList] = None,
) -> ListObservationsOutput

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

Parameters:

  • filters (Optional[ObservationFilters], default: None ) –

    Criteria restricting which observations are returned.

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

    The maximum number of observations to return in a single page. Valid range is 1 to 100. When omitted, the service defaults to 50.

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

    Pagination token from a previous response, to retrieve the next page.

  • observation_ids (Optional[ObservationIdList], default: None ) –

    Optional batch-get filter. When set, observations are fetched by ID under the caller's account. Pagination still applies: maxResults bounds the returned observations 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. observationIds is mutually exclusive with filters: passing filters alongside observationIds returns a ValidationException. Use a follow-up ListObservations call without observationIds for filtered queries.

Raises:

Examples:

List the most severe open observations The following example lists observations, filtered to the HIGH severity in the ACTIVE status, most recently updated first. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> client.list_observations(filters={'status': ['ACTIVE'], 'severity': ['HIGH']}, max_results=50)
Source code in docs_src/capo_cloudwatchomni/_services/cloud_watch_omni.py
def list_observations(
    self,
    *,
    config_overrides: Optional[CloudWatchOmniClientConfig] = None,
    filters: Optional[
        "capo_cloudwatchomni.types.observation_filters.ObservationFilters"
    ] = None,
    max_results: Optional[int] = None,
    next_token: Optional[
        "capo_cloudwatchomni.types.pagination_token.PaginationToken"
    ] = None,
    observation_ids: Optional[
        "capo_cloudwatchomni.types.observation_id_list.ObservationIdList"
    ] = None,
) -> "capo_cloudwatchomni.types.list_observations_output.ListObservationsOutput":
    """This operation is part of Observations, which is in preview release for Amazon CloudWatch Omni and is subject to change. Lists observations matching the given filters.

    Args:
        filters: Criteria restricting which observations are returned.
        max_results: The maximum number of observations to return in a single page. Valid range is 1 to 100. When omitted, the service defaults to 50.
        next_token: Pagination token from a previous response, to retrieve the next page.
        observation_ids: Optional batch-get filter. When set, observations are fetched by ID under the caller's account. Pagination still applies: maxResults bounds the returned observations 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. observationIds is mutually exclusive with filters: passing filters alongside observationIds returns a ValidationException. Use a follow-up ListObservations call without observationIds 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 the most severe open observations
        The following example lists observations, filtered to the HIGH severity in the ACTIVE status, most recently updated first. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> client.list_observations(filters={'status': ['ACTIVE'], 'severity': ['HIGH']}, max_results=50)
    """

    def _handler(
        req: "OperationRequest[capo_cloudwatchomni.types.list_observations_input.ListObservationsInput]",
    ) -> OperationResponse[
        "capo_cloudwatchomni.types.list_observations_output.ListObservationsOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.list_observations

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

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

        return capo_cloudwatchomni.types.list_observations_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("ListObservations", redact_output=_redact_output),
    )
    input_: capo_cloudwatchomni.types.list_observations_input.ListObservationsInput = {}
    if filters is not None:
        input_["filters"] = filters
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if observation_ids is not None:
        input_["observation_ids"] = observation_ids

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