Updated on 2025-09-05 GMT+08:00

Querying Error Logs Through LTS

Function

This API is used to query error logs of a DB instance when Log Tank Service (LTS) is available in the current region.

URI

  • URI format

    POST /v3/{project_id}/instances/{instance_id}/error-logs

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID of a tenant in a region.

    To obtain the value, see Obtaining a Project ID.

    instance_id

    Yes

    ID of the instance to be queried.

Request

Table 2 Parameters

Parameter

Mandatory

Type

Description

start_time

Yes

String

Start time in the "yyyy-mm-ddThh:mm:ssZ" format.

T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800. The start time cannot be more than one month earlier than the current time.

end_time

Yes

String

End time in the "yyyy-mm-ddThh:mm:ssZ" format.

T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800. Only error logs generated in the past month can be queried.

level

No

String

Log level. The default value is ALL.

Enumerated values:

  • ALL
  • INFO
  • LOG
  • WARNING
  • ERROR
  • FATAL
  • PANIC
  • NOTE

line_num

No

String

Sequence number of a log event. This parameter is not required for the first query, but is required for subsequent pagination queries. The value can be obtained from the response of the last query. The value of line_num should be between the values of start_time and end_time.

search_type

No

String

Search mode. The default value is forwards. This parameter is used together with line_num. The search starts from line_num and is performed forwards or backwards.

limit

No

Integer

Number of records (query results) displayed on each page. The number ranges from 1 to 100. The default value is 10.

Example Request

Query error logs. Each page contains 10 records.
POST https://{endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances/cee5265e1e5845649e354841234567dfin01/error-logs

{
    "start_time":"2023-01-05T08:00:00+0800",
    "end_time":"2023-01-11T20:00:00+0800",
    "limit":10,
    "line_num":"1672908793000000000",
    "search_type":"forwards"
}

Response

  • Normal response
    Table 3 Parameters

    Parameter

    Type

    Description

    error_log_list

    Array of objects

    Error logs.

    For details, see Table 4.

    Table 4 error_log_list field data structure description

    Parameter

    Type

    Description

    time

    String

    Time in the UTC format.

    level

    String

    Log level.

    content

    String

    Error log content.

    line_num

    String

    Sequence number of a log event.

  • Example normal response
    {
      "error_log_list" : [ { 
        "time" : "2022-08-23T22:59:17Z", 
        "level" : "WARNING", 
        "content" : "Occur error when reading bytes from a network handler. Client actively closes the connection.", 
        "line_num" : "1595659490239433658" 
      } ] 
    }
  • Abnormal response

    For details, see Abnormal Request Results.

Status Code

Error Code

For details, see Error Codes.