Updated on 2023-11-27 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

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3.1/0483b6b16e954cb88930a360d2c4e663/instances/6ade8143870047b8999aba8f1891b48ein02/error-logs

Table 1 Request parameters

Name

Type

IN

Mandatory

Description

X-Auth-Token

string

header

Yes

User token obtained from IAM. For details, see Authentication.

project_id

string

path

Yes

Project ID of a tenant in a region. Obtain the project ID by following the instructions in 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.

Requests

  • Parameter description
    Table 2 Parameter description

    Name

    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. Enumerated values:

    • 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 8. Nodes that can be queried:

    • Shard nodes in a cluster instance.
    • All nodes in a replica set or single node 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"] 
    }

Responses

  • Parameter description
    Table 3 Parameter description

    Name

    Type

    Description

    error_logs

    Array of objects

    Error log details.

    For details, see Table 4.

    Table 4 Data structure description of field error_log_list

    Name

    Type

    Description

    node_name

    String

    Node name.

    node_id

    String

    Node ID.

    raw_message

    String

    Error 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.

  • Response example
    { 
      "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" 
      } ] 
    }

SDK

Click Document Database Service DDS SDK to download the SDK or view the SDK document. To learn how to install and authenticate an SDK, read the Usage section.

Status Code

For details, see Status Code.

Error Code

For details, see Error Code.