Skip to content

get_container_log async

get_container_log(
    service_name: ContainerServiceName,
    container_name: string,
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
    start_time: Optional[IsoDate] = None,
    end_time: Optional[IsoDate] = None,
    filter_pattern: Optional[string] = None,
    page_token: Optional[string] = None,
) -> GetContainerLogResult

Returns the log events of a container of your Amazon Lightsail container service.

If your container service has more than one node (i.e., a scale greater than 1), then the log events that are returned for the specified container are merged from all nodes on your container service.

Container logs are retained for a certain amount of time. For more information, see Amazon Lightsail endpoints and quotas in the Amazon Web Services General Reference.

Parameters:

  • service_name (ContainerServiceName) –

    The name of the container service for which to get a container log.

  • container_name (string) –

    The name of the container that is either running or previously ran on the container service for which to return a log.

  • start_time (Optional[IsoDate], default: None ) –

    The start of the time interval for which to get log data.

    Constraints:

    • Specified in Coordinated Universal Time (UTC).

    • Specified in the Unix time format.

      For example, if you wish to use a start time of October 1, 2018, at 8 PM UTC, specify 1538424000 as the start time.

    You can convert a human-friendly time to Unix time format using a converter like Epoch converter.

  • end_time (Optional[IsoDate], default: None ) –

    The end of the time interval for which to get log data.

    Constraints:

    • Specified in Coordinated Universal Time (UTC).

    • Specified in the Unix time format.

      For example, if you wish to use an end time of October 1, 2018, at 9 PM UTC, specify 1538427600 as the end time.

    You can convert a human-friendly time to Unix time format using a converter like Epoch converter.

  • filter_pattern (Optional[string], default: None ) –

    The pattern to use to filter the returned log events to a specific term.

    The following are a few examples of filter patterns that you can specify:

    • To return all log events, specify a filter pattern of "".

    • To exclude log events that contain the ERROR term, and return all other log events, specify a filter pattern of "-ERROR".

    • To return log events that contain the ERROR term, specify a filter pattern of "ERROR".

    • To return log events that contain both the ERROR and Exception terms, specify a filter pattern of "ERROR Exception".

    • To return log events that contain the ERROR or the Exception term, specify a filter pattern of "?ERROR ?Exception".

  • page_token (Optional[string], default: None ) –

    The token to advance to the next page of results from your request.

    To get a page token, perform an initial GetContainerLog request. If your results are paginated, the response will return a next page token that you can specify as the page token in a subsequent request.

Raises:

  • AccessDeniedException –

    Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.

  • InvalidInputException –

    Lightsail throws this exception when user input does not conform to the validation rules of an input field.

    Domain and distribution APIs are only available in the N. Virginia (us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to us-east-1 to create, view, or edit these resources.

  • NotFoundException –

    Lightsail throws this exception when it cannot find a resource.

  • RegionSetupInProgressException –

    Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.

  • ServiceException –

    A general service exception.

  • UnauthenticatedException –

    Lightsail throws this exception when the user has not been authenticated.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_lightsail/_services/async_lightsail.py
async def get_container_log(
    self,
    service_name: "capo_lightsail.types.container_service_name.ContainerServiceName",
    container_name: "capo_lightsail.types.string.string",
    *,
    config_overrides: Optional[AsyncLightsailClientConfig] = None,
    start_time: Optional["capo_lightsail.types.iso_date.IsoDate"] = None,
    end_time: Optional["capo_lightsail.types.iso_date.IsoDate"] = None,
    filter_pattern: Optional["capo_lightsail.types.string.string"] = None,
    page_token: Optional["capo_lightsail.types.string.string"] = None,
) -> "capo_lightsail.types.get_container_log_result.GetContainerLogResult":
    """<p>Returns the log events of a container of your Amazon Lightsail container service.</p> <p>If your container service has more than one node (i.e., a scale greater than 1), then the log events that are returned for the specified container are merged from all nodes on your container service.</p> <note> <p>Container logs are retained for a certain amount of time. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/lightsail.html">Amazon Lightsail endpoints and quotas</a> in the <i>Amazon Web Services General Reference</i>.</p> </note>

    Args:
        service_name: <p>The name of the container service for which to get a container log.</p>
        container_name: <p>The name of the container that is either running or previously ran on the container service for which to return a log.</p>
        start_time: <p>The start of the time interval for which to get log data.</p> <p>Constraints:</p> <ul> <li> <p>Specified in Coordinated Universal Time (UTC).</p> </li> <li> <p>Specified in the Unix time format.</p> <p>For example, if you wish to use a start time of October 1, 2018, at 8 PM UTC, specify <code>1538424000</code> as the start time.</p> </li> </ul> <p>You can convert a human-friendly time to Unix time format using a converter like <a href="https://www.epochconverter.com/">Epoch converter</a>.</p>
        end_time: <p>The end of the time interval for which to get log data.</p> <p>Constraints:</p> <ul> <li> <p>Specified in Coordinated Universal Time (UTC).</p> </li> <li> <p>Specified in the Unix time format.</p> <p>For example, if you wish to use an end time of October 1, 2018, at 9 PM UTC, specify <code>1538427600</code> as the end time.</p> </li> </ul> <p>You can convert a human-friendly time to Unix time format using a converter like <a href="https://www.epochconverter.com/">Epoch converter</a>.</p>
        filter_pattern: <p>The pattern to use to filter the returned log events to a specific term.</p> <p>The following are a few examples of filter patterns that you can specify:</p> <ul> <li> <p>To return all log events, specify a filter pattern of <code>""</code>.</p> </li> <li> <p>To exclude log events that contain the <code>ERROR</code> term, and return all other log events, specify a filter pattern of <code>"-ERROR"</code>.</p> </li> <li> <p>To return log events that contain the <code>ERROR</code> term, specify a filter pattern of <code>"ERROR"</code>.</p> </li> <li> <p>To return log events that contain both the <code>ERROR</code> and <code>Exception</code> terms, specify a filter pattern of <code>"ERROR Exception"</code>.</p> </li> <li> <p>To return log events that contain the <code>ERROR</code> <i>or</i> the <code>Exception</code> term, specify a filter pattern of <code>"?ERROR ?Exception"</code>.</p> </li> </ul>
        page_token: <p>The token to advance to the next page of results from your request.</p> <p>To get a page token, perform an initial <code>GetContainerLog</code> request. If your results are paginated, the response will return a next page token that you can specify as the page token in a subsequent request.</p>

    Raises:
        capo_lightsail.errors.access_denied_exception.AccessDeniedException: <p>Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.</p>
        capo_lightsail.errors.invalid_input_exception.InvalidInputException: <p>Lightsail throws this exception when user input does not conform to the validation rules of an input field.</p> <note> <p>Domain and distribution APIs are only available in the N. Virginia (<code>us-east-1</code>) Amazon Web Services Region. Please set your Amazon Web Services Region configuration to <code>us-east-1</code> to create, view, or edit these resources.</p> </note>
        capo_lightsail.errors.not_found_exception.NotFoundException: <p>Lightsail throws this exception when it cannot find a resource.</p>
        capo_lightsail.errors.region_setup_in_progress_exception.RegionSetupInProgressException: <p>Lightsail throws this exception when an operation is performed on resources in an opt-in Region that is currently being set up.</p>
        capo_lightsail.errors.service_exception.ServiceException: <p>A general service exception.</p>
        capo_lightsail.errors.unauthenticated_exception.UnauthenticatedException: <p>Lightsail throws this exception when the user has not been authenticated.</p>
        capo_lightsail.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_lightsail.types.get_container_log_request.GetContainerLogRequest]",
    ) -> AsyncOperationResponse[
        "capo_lightsail.types.get_container_log_result.GetContainerLogResult"
    ]:
        import capo_lightsail._operations.lightsail_20161128.get_container_log

        (
            output,
            http_response,
        ) = await capo_lightsail._operations.lightsail_20161128.get_container_log.async_get_container_log(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("GetContainerLog")
    )
    input_: capo_lightsail.types.get_container_log_request.GetContainerLogRequest = {
        "service_name": service_name,
        "container_name": container_name,
    }
    if start_time is not None:
        input_["start_time"] = start_time
    if end_time is not None:
        input_["end_time"] = end_time
    if filter_pattern is not None:
        input_["filter_pattern"] = filter_pattern
    if page_token is not None:
        input_["page_token"] = page_token

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