Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Querying Database Slow Logs (New)

Updated on 2023-11-24 GMT+08:00

API Description

This API is used to query slow logs by keyword or database table name.

Restrictions

  • Operators (such as &&, ||, AND, OR, NOT, *, ?, :, >, <, =, , and ) contained in raw logs cannot be used to search for logs.
  • A maximum of 100 records can be queried on each page.
  • Slow query logs can be stored for a maximum of 30 days.

URI

  • URI format

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

  • URI example

    https://dds.ap-southeast-1.myhuaweicloud.com/v3.1/0483b6b16e954cb88930a360d2c4e663/instances/6ade8143870047b8999aba8f1891b48ein02/slow-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. 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.

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.

    NOTE:

    The current query starts from the next log of line_num, excluding the log of line_num.

    operate_type

    String

    No

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

    Its value can be any of the following:

    • insert
    • query
    • update
    • remove
    • getmore
    • command
    • killcursors

    node_id

    String

    No

    Node ID. For details, see Table 8.

    If this parameter is left blank, all nodes in the instance can be queried.

    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.

    database_keywords

    Array of strings

    No

    Fuzzy search for logs based on multiple database keywords, indicating that at least one keyword is matched.

    • Only fuzzy search by keyword prefix is supported. A maximum of 10 keywords are supported.
    • Each keyword can contain a maximum of 64 characters.

    collection_keywords

    Array of strings

    No

    Fuzzy search for logs based on multiple database table name keywords, indicating that at least one keyword is matched.

    • Only fuzzy search by keyword prefix is supported. A maximum of 10 keywords are supported.
    • Each keyword can contain a maximum of 128 characters.

    max_cost_time

    Integer

    No

    Logs can be searched based on the maximum execution duration.

    Unit: ms

    min_cost_time

    Integer

    No

    Logs can be searched based on the minimum execution duration.

    Unit: ms

Example Request

Querying slow logs of a DB instance by keyword, in which limit is set to 100, max_cost_time is set to 100, and min_cost_time is set to 50
{ 
  "start_time" : "2022-09-06T10:41:14+0800", 
  "end_time" : "2022-09-16T10:41:14+0800", 
  "limit" : 100, 
  "line_num" : "1595659490239433658", 
  "operate_type" : "query",
  "node_id" : "dbd0b65ed0c34125a0b04d4e5ba67e66no02", 
  "keywords" : [ "response", "oplog" ],
  "database_keywords" : [ "testDB" ], 
  "collection_keywords" : [ "testCollection" ], 
  "max_cost_time" : 100, 
  "min_cost_time" : 50
}

Responses

  • Parameter description
    Table 3 Parameter description

    Name

    Type

    Description

    slow_logs

    Array of objects

    Slow log information.

    For details, see Table 4.

    Table 4 Data structure description of field slowLogDetail

    Name

    Type

    Description

    node_name

    String

    Node name.

    node_id

    String

    Node ID.

    whole_message

    String

    Statement.

    operate_type

    String

    Statement type.

    cost_time

    Integer

    Execution time.

    Unit: ms

    lock_time

    Integer

    Lock wait time.

    Unit: μs

    docs_returned

    Integer

    Number of returned documents.

    docs_scanned

    Integer

    Number of scanned documents.

    database

    String

    Name of the database which the log belongs to.

    collection

    String

    Name of the database table which the log belongs to.

    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
    { 
      "slow_logs" : [ { 
        "node_name" : "Test_replica_node_2", 
        "node_id" : "dbd0b65ed0c34125a0b04d4e5ba67e66no02", 
        "whole_message" : "{\"responseLength\": 230, \"ts\": {\"$date\": 1605480486800}, \"ninserted\": 1, \"locks\": {\"oplog\": {\"acquireCount\": {\"w\": 1}}, \"Global\": {\"acquireCount\": {\"r\": 3, \"w\": 2}}, \"Collection\": {\"acquireCount\": {\"w\": 2}}, \"Database\": {\"acquireCount\": {\"w\": 3}}}, \"numYield\": 0, \"ns\": \"geographySpace.tiles\"}", 
        "operate_type" : "query", 
        "cost_time" : 60, 
        "lock_time" : 10, 
        "docs_returned" : 60, 
        "docs_scanned" : 70, 
        "database" : "testDB", 
        "collection" : "testCollection", 
        "log_time" : "2022-09-15T22:49:38.643000Z", 
        "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 more information, see Status Code.

Error Code

For more information, see Error Code.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback