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

Querying Slow Query Logs of a GeminiDB Influx Instance

Function

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

Constraints

  • Operators &, ||, AND, OR, NOT, *, ?, :, >, <, =, ≥, and ≤ cannot be used to search for logs.
  • 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 slow query logs can be stored for a maximum of 30 days.

URI

POST https://{Endpoint}/v3/{project_id}/influxdb/instances/{instance_id}/slow-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.

operate_type

No

String

Statement type. If this parameter is left empty, all statement types are queried.

Value options:

  • SELECT
  • DELETE
  • SHOW
  • DROP
  • CREATE
  • ALTER

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

String

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 up to 512 characters.

max_cost_time

No

Integer

Logs can be searched based on the maximum execution duration. Unit: ms

min_cost_time

No

Integer

Logs can be searched based on the minimum execution duration. Unit: ms

database

No

String

Database name.

retention_policy

No

String

Retention policy.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

slow_logs

Array of objects

GeminiDB Influx slow query logs. For details, see Table 5.

Table 5 InfluxdbSlowLogDetail

Parameter

Type

Description

node_id

String

Node ID.

node_name

String

Node name.

whole_message

String

Statement.

operate_type

String

SQL statement type.

cost_time

String

Execution time. Unit: ms

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.

database

String

Database name.

retention_policy

String

Retention policy.

line_num

String

Sequence number of a log event.

Example Requests

Querying 100 slow query logs that consist of SELECT statements from 2023-07-06 10:41:14 to 2023-07-10 10:41:14.

POST https://{Endpoint}/v3/2900b7b8d03e4619b8db8d43bc6234ee/influxdb/instances/4466bd981011413cb98514e1cc20fdb0in13/slow-logs 
 
{ 
  "start_time" : "2023-07-06T10:41:14+0800", 
  "end_time" : "2023-07-10T10:41:14+0800", 
  "limit" : 100, 
  "line_num" : "1595659490239433658", 
  "operate_type" : "SELECT", 
  "node_id" : "8b76c35e91eb4c9d82fe25417d750cb5no13", 
  "max_cost_time" : 100, 
  "min_cost_time" : 50, 
  "database" : "dbname" ,
  "retention_policy" : "monitor" 
}

Example Responses

Status code: 200

Success

{ 
  "slow_logs" : [ { 
    "node_name" : "test_priam_node_1", 
    "node_id" : "8b76c35e91eb4c9d82fe25417d750cb5no13", 
    "whole_message" : "SELECT tag,field FROM dbname..mst WHERE time >= '1' AND time < '2'", 
    "operate_type" : "SELECT", 
    "cost_time" : 60, 
    "log_time" : "2023-07-04T05:42:32.000+0000", 
    "database" : "dbname", 
    "line_num" : "1595659490239433659", 
    "retention_policy" : "monitor" 
  } ] 
}

Status Codes

For details, see Status Codes.

Error Codes

For details, see Error Codes.