Help Center/ GeminiDB/ API Reference/ APIs v3 (Recommended)/ Logs/ Querying Error Logs of a GeminiDB Mongo Instance
Updated on 2024-08-08 GMT+08:00

Querying Error Logs of a GeminiDB Mongo Instance

Function

This API is used to query error logs of GeminiDB Mongo instances. Searching for error logs by keyword is supported.

Constraints

  • The following operators are not supported: &&, ||, AND, OR, NOT, *, ?, :, >, <, =, ≥, and ≤
  • The query must be within the period specified by start_time and end_time.
  • The value of line_num must be obtained from the log information returned for the last query. This parameter is optional for the first query.
  • A maximum of 100 records can be queried on each page, and error logs can be stored for a maximum of 30 days.

URI

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

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region. To obtain this value, see Obtaining a Project ID.

instance_id

Yes

String

Instance ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

start_time

Yes

String

Start time in the yyyy-mm-ddThh:mm:ssZ format. T is the separator between calendar and hourly notation of time. Z indicates the time zone offset.

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

end_time

Yes

String

End time in the yyyy-mm-ddThh:mm:ssZ format. T is the separator between calendar and hourly notation of time. Z indicates the time zone offset.

The end time cannot be later than the current time.

limit

Yes

Integer

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

line_num

No

String

Sequence number of a log event. This parameter is not required for the first query, but is required for the next 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

No

String

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

Value options:

  • Warning
  • Error

node_id

No

String

Node ID. If this parameter is left blank, all nodes in the instance can be queried. For details about the value, see field id in Table 10.

keywords

No

Array of strings

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

  • A maximum of 10 keywords are supported.
  • Each keyword can contain a maximum of 512 characters.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

error_logs

Array of objects

Error log details. For details, see Table 5.

Table 5 MongodbErrorLogDetail

Parameter

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 calendar and hourly notation of time. Z indicates the time zone offset.

line_num

String

Sequence number of a log event.

Example Requests

POST https://{Endpoint}/v3/619d3e78f61b4be68bc5aa0b59edcf7b/mongodb/instances/916de02c35fe4abaa3e707ebd916d3f8in10/error-logs 
 
{ 
  "start_time" : "2023-01-06T10:41:14+0800", 
  "end_time" : "2023-01-10T10:41:14+0800", 
  "limit" : 100, 
  "line_num" : "1595659490239433658", 
  "severity" : "Warning", 
  "node_id" : "dfe41edcb2a1483c96ddf61cc0cee237no10", 
  "keywords" : [ "error" ] 
}

Example Responses

Status code: 200

Success

{ 
  "error_logs" : [ { 
    "node_name" : "test_replica_node_1", 
    "node_id" : "dfe41edcb2a1483c96ddf61cc0cee237no10", 
    "raw_message" : "W TEST [test001] test error log", 
    "severity" : "Warning", 
    "log_time" : "2023-01-09T12:55:39.398+0000", 
    "line_num" : "1595659490239433659" 
  } ] 
}

Status Codes

For details, see Status Codes.

Error Codes

For details, see Error Codes.