Skip to content

download_db_log_file_portion async

download_db_log_file_portion(
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional[String] = None,
    log_file_name: Optional[String] = None,
    marker: Optional[String] = None,
    number_of_lines: Optional[Integer] = None,
) -> DownloadDBLogFilePortionDetails

Downloads all or a portion of the specified log file, up to 1 MB in size.

This command doesn't apply to RDS Custom.

This operation uses resources on database instances. Because of this, we recommend publishing database logs to CloudWatch and then using the GetLogEvents operation. For more information, see GetLogEvents in the Amazon CloudWatch Logs API Reference.

Parameters:

  • db_instance_identifier (Optional[String], default: None ) –

    The customer-assigned name of the DB instance that contains the log files you want to list.

    Constraints:

    • Must match the identifier of an existing DBInstance.

  • log_file_name (Optional[String], default: None ) –

    The name of the log file to be downloaded.

  • marker (Optional[String], default: None ) –

    The pagination token provided in the previous request or "0". If the Marker parameter is specified the response includes only records beyond the marker until the end of the file or up to NumberOfLines.

  • number_of_lines (Optional[Integer], default: None ) –

    The number of lines to download. If the number of lines specified results in a file over 1 MB in size, the file is truncated at 1 MB in size.

    If the NumberOfLines parameter is specified, then the block of lines returned can be from the beginning or the end of the log file, depending on the value of the Marker parameter.

    • If neither Marker or NumberOfLines are specified, the entire log file is returned up to a maximum of 10000 lines, starting with the most recent log entries first.

    • If NumberOfLines is specified and Marker isn't specified, then the most recent lines from the end of the log file are returned.

    • If Marker is specified as "0", then the specified number of lines from the beginning of the log file are returned.

    • You can download the log file in blocks of lines by specifying the size of the block using the NumberOfLines parameter, and by specifying a value of "0" for the Marker parameter in your first request. Include the Marker value returned in the response as the Marker value for the next request, continuing until the AdditionalDataPending response element returns false.

Raises:

Examples:

To download a DB log file The following example downloads only the latest part of your log file.

>>> await client.download_db_log_file_portion(db_instance_identifier='test-instance', log_file_name='log.txt')
Source code in docs_src/capo_rds/_services/async_rds.py
async def download_db_log_file_portion(
    self,
    *,
    config_overrides: Optional[AsyncRDSClientConfig] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    log_file_name: Optional["capo_rds.types.string.String"] = None,
    marker: Optional["capo_rds.types.string.String"] = None,
    number_of_lines: Optional["capo_rds.types.integer.Integer"] = None,
) -> "capo_rds.types.download_db_log_file_portion_details.DownloadDBLogFilePortionDetails":
    """<p>Downloads all or a portion of the specified log file, up to 1 MB in size.</p> <p>This command doesn't apply to RDS Custom.</p> <note> <p>This operation uses resources on database instances. Because of this, we recommend publishing database logs to CloudWatch and then using the GetLogEvents operation. For more information, see <a href="https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_GetLogEvents.html">GetLogEvents</a> in the <i>Amazon CloudWatch Logs API Reference</i>.</p> </note>

    Args:
        db_instance_identifier: <p>The customer-assigned name of the DB instance that contains the log files you want to list.</p> <p>Constraints:</p> <ul> <li> <p>Must match the identifier of an existing DBInstance.</p> </li> </ul>
        log_file_name: <p>The name of the log file to be downloaded.</p>
        marker: <p>The pagination token provided in the previous request or "0". If the Marker parameter is specified the response includes only records beyond the marker until the end of the file or up to NumberOfLines.</p>
        number_of_lines: <p>The number of lines to download. If the number of lines specified results in a file over 1 MB in size, the file is truncated at 1 MB in size.</p> <p>If the NumberOfLines parameter is specified, then the block of lines returned can be from the beginning or the end of the log file, depending on the value of the Marker parameter.</p> <ul> <li> <p>If neither Marker or NumberOfLines are specified, the entire log file is returned up to a maximum of 10000 lines, starting with the most recent log entries first.</p> </li> <li> <p>If NumberOfLines is specified and Marker isn't specified, then the most recent lines from the end of the log file are returned.</p> </li> <li> <p>If Marker is specified as "0", then the specified number of lines from the beginning of the log file are returned.</p> </li> <li> <p>You can download the log file in blocks of lines by specifying the size of the block using the NumberOfLines parameter, and by specifying a value of "0" for the Marker parameter in your first request. Include the Marker value returned in the response as the Marker value for the next request, continuing until the AdditionalDataPending response element returns false.</p> </li> </ul>

    Raises:
        capo_rds.errors.db_instance_not_found_fault.DBInstanceNotFoundFault: <p> <code>DBInstanceIdentifier</code> doesn't refer to an existing DB instance.</p>
        capo_rds.errors.db_instance_not_ready_fault.DBInstanceNotReadyFault: <p>An attempt to download or examine log files didn't succeed because an Aurora Serverless v2 instance was paused.</p>
        capo_rds.errors.db_log_file_not_found_fault.DBLogFileNotFoundFault: <p> <code>LogFileName</code> doesn't refer to an existing DB log file.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To download a DB log file
        The following example downloads only the latest part of your log file.

        >>> await client.download_db_log_file_portion(db_instance_identifier='test-instance', log_file_name='log.txt')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_rds.types.download_db_log_file_portion_message.DownloadDBLogFilePortionMessage]",
    ) -> AsyncOperationResponse[
        "capo_rds.types.download_db_log_file_portion_details.DownloadDBLogFilePortionDetails"
    ]:
        import capo_rds._operations.amazon_rd_sv19.download_db_log_file_portion

        (
            output,
            http_response,
        ) = await capo_rds._operations.amazon_rd_sv19.download_db_log_file_portion.async_download_db_log_file_portion(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_rds.types.download_db_log_file_portion_details.DownloadDBLogFilePortionDetails",
    ) -> dict[str, Any]:
        import capo_rds.types.download_db_log_file_portion_details

        return capo_rds.types.download_db_log_file_portion_details.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("DownloadDBLogFilePortion", redact_output=_redact_output),
    )
    input_: capo_rds.types.download_db_log_file_portion_message.DownloadDBLogFilePortionMessage = {}
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if log_file_name is not None:
        input_["log_file_name"] = log_file_name
    if marker is not None:
        input_["marker"] = marker
    if number_of_lines is not None:
        input_["number_of_lines"] = number_of_lines

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