Updated on 2026-01-08 GMT+08:00

Querying Database Error Logs (New)

API Description

This API is used to query database error logs.

Restrictions

  • Operators &, ||, AND, OR, NOT, *, ?, :, >, <, =, ≥, and ≤ cannot be used to search for logs.
  • A maximum of 100 records can be queried on each page, and logs can be stored for a maximum of 30 days.

URI

  • URI format

    POST https://{Endpoint}/v3.1/{project_id}/instances/{instance_id}/error-logs

Table 1 Path parameters

Name

Type

IN

Mandatory

Description

project_id

string

path

Yes

Project ID of a tenant in a region. To obtain the project ID, see Obtaining a Project ID.

instance_id

string

path

Yes

Instance ID, which can be obtained by calling the API described in Querying Instances and Details. If you do not have an instance, call the API described in Creating a DB Instance to create one.

Request Parameters

Table 2 Request header parameters

Parameter

Type

IN

Mandatory

Description

X-Auth-Token

string

header

Yes

User token

Table 3 Parameter description

Parameter

Type

Mandatory

Description

start_time

String

Yes

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.

CAUTION:

The start time cannot be 30 days earlier than the current time.

end_time

String

Yes

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.

NOTE:

The end time cannot be later than the current time.

limit

Integer

Yes

Number of logs to be queried each time. The maximum value is 100.

line_num

String

No

Sequence number of a log event. This parameter is not required for the first query, but is required for the next page query. The value can be obtained from the response of the last query. The current query starts from the next log of line_num, excluding the log of line_num.

severity

String

No

Log level. If this parameter is left blank, logs of all levels can be queried. The value can be:

  • WARNING
  • ERROR

search_type

String

No

Log query mode, which must be used together with line_num. The log of line_num is used as the start point.

  • If this parameter is set to backwards, logs of the limit size on the previous page are queried.
  • If this parameter is set to forwards, logs of the limit size on the next page are queried.
  • If this parameter is not specified, the default value forwards is used.

Enumerated values:

  • backwards
  • forwards

node_id

String

No

Node ID. If this parameter is left blank, all nodes in the instance can be queried. For details, see id in Table 9. Nodes that can be queried:

  • Shard nodes in a cluster instance.
  • All nodes in a replica set instance.

keywords

Array of strings

No

Full-text log search based on multiple keywords, indicating that all keywords are matched.

  • Only fuzzy search by keyword prefix is supported. A maximum of 10 keywords are supported.
  • Each keyword can contain a maximum of 512 characters.
  • Example request
    { 
      "start_time" : "2023-01-06T10:41:14+0800", 
      "end_time" : "2023-01-09T13:41:14+0800", 
      "limit" : 100, 
      "line_num" : "1595659490239433658", 
      "severity" : "Warning", 
      "search_type" : "forwards",
      "node_id" : "dbd0b65ed0c34125a0b04d4e5ba67e66no02",
      "keywords" : ["Unable", "NETWORK"] 
    }

Response Parameters

Table 4 Parameter description

Parameter

Type

Description

error_logs

Array of objects

Error log details.

For details, see Table 5.

Table 5 Data structure description of field error_log_list

Parameter

Type

Description

node_name

String

Node name.

node_id

String

Node ID.

raw_message

String

Description.

severity

String

Log level.

log_time

String

UTC time when a log is generated. The format is yyyy-mm-ddThh:mm:ssZ. T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset.

line_num

String

Sequence number of a log event.

  • Example response
    { 
      "error_logs" : [ { 
        "node_name" : "Test_replica_node_2", 
        "node_id" : "dbd0b65ed0c34125a0b04d4e5ba67e66no02", 
        "raw_message" : "W NETWORK  [ShardServerCatalogCacheLoader-214] Unable to reach primary for set shard_2", 
        "severity" : "Warning", 
        "log_time" : "2023-01-09T12:55:39.398+0000", 
        "line_num" : "1595659490239433659" 
      } ] 
    }

Status Code

For details, see Status Code.

Error Code

For details, see Error Code.