Help Center/ GaussDB/ API Reference/ APIs (Recommended)/ SQL Explorer/ Querying SQL Explorer Status Records
Updated on 2025-10-20 GMT+08:00

Querying SQL Explorer Status Records

Function

This API is used to query SQL Explorer status records. Before calling this API:

Debugging

You can debug this API in API Explorer.

URI

GET /v3/{project_id}/instances/{instance_id}/full-sql-switches

Table 1 Parameter description

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region.

To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are allowed.

Default Value

N/A

instance_id

Yes

String

Definition

Instance ID, which uniquely identifies an instance.

Constraints

N/A

Range

The value can contain 36 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token.

You can obtain the token by calling the IAM API used to obtain a user token.

After the request is processed, the value of X-Subject-Token in the message header is the token value.

Constraints

N/A

Range

N/A

Default Value

N/A

X-Language

No

String

Definition

Language.

Constraints

N/A

Range

  • zh-cn
  • en-us

Default Value

en-us

Table 3 Request query parameters

Parameter

Mandatory

Type

Description

offset

No

Integer

Definition

Index offset.

Constraints

N/A

Range

0–2,147,483,647

Default Value

0: The query starts from the first data record.

limit

No

Integer

Definition

Number of records returned by a query.

Constraints

N/A

Range

1–1000

Default Value

100

Response Parameters

Table 4 Response body parameters

Parameter

Type

Description

total_count

Integer

Definition

Total number of records.

Range

N/A

full_sql_switches

Array of FullSqlSwitch

Definition

Status records.

For details, see Table 5.

allowed_sql_types

Array of SqlTypeRangeConfig

Definition

Selectable types of SQL statements to be collected. This parameter serves as a reference for configuring SQL Explorer enablement.

For details, see Table 7.

parser

String

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

Range

N/A

Table 5 FullSqlSwitch

Parameter

Type

Description

is_open

Boolean

Definition

Whether SQL Explorer is enabled.

Range

  • true: enabled
  • false: disabled

begin_time

String

Definition

Start time of the function status. 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.

Range

N/A

end_time

String

Definition

End time of the function status. 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.

Range

If the value is null, the function status remains unchanged.

save_days

Integer

Definition

Maximum number of days for storing full SQL data collected.

Range

[1,30]

storage_mode

String

Definition

Storage type of full SQL data.

Range

LTS: Log Tank Service (LTS)

is_exclude_sys_user

Boolean

Definition

Whether to exclude system users.

Range

  • true: System users are excluded.
  • false: System users are not excluded.

lts_config

Object of LtsConfig

Definition

LTS interconnection configuration information. For details, see Table 6.

sql_type_range

Array of SqlTypeRangeConfig

Definition

Types of SQL statements to be collected. For details, see Table 7.

file_data_type

String

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

Range

N/A

bind_obs_info

Object

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

storage_device_id

String

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

Range

N/A

save_months

Integer

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

Range

N/A

online_hours

Integer

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

Range

N/A

parser

String

Definition

Reserved field, which is not involved in Huawei Cloud. Ignore it.

Range

N/A

Table 6 LtsConfig

Parameter

Type

Description

group_ttl_in_days

Integer

Definition

Maximum number of days for storing data in an LTS log group.

Range

[1,30]

group_log_type

String

Definition

LTS log group type.

Range

Generally, the value is asp_log, which is identified as a log group dedicated to intelligent O&M.

log_group_name

String

Definition

LTS log group name.

Range

Generally, the value is GROUP_GAUSSDB_APS-instance-ID.

log_group_id

String

Definition

LTS log group ID.

Range

N/A

log_stream_name

String

Definition

LTS log stream name.

Range

Generally, the value is STREAM_APS_FULL_SQL-instance-ID.

log_stream_id

String

Definition

LTS log stream ID.

Range

N/A

stream_log_type

String

Definition

LTS log stream type.

Range

Generally, the value is full_sql, which is identified as a log stream dedicated for SQL Explorer.

stream_ttl_in_days

Integer

Definition

Maximum number of days for storing data in an LTS log stream.

Range

[1,30]

stream_structure_config_id

String

Definition

ID of the structured configuration for the LTS log stream.

Range

N/A

stream_index_config_id

String

Definition

ID of the index configuration for the LTS log stream.

Range

N/A

Table 7 SqlTypeRangeConfig

Parameter

Type

Description

category

String

Definition

Category name of SQL statements.

  • Common SQL statements are classified into six categories. Each category corresponds to a fixed list of SQL statements, which are matched by prefix.
  • In other scenarios, you can use custom categories. You can set the prefixes for SQL statements to be collected as required.

Range

  • all: All SQL statements are collected.
  • ddl: Only DDL statements are collected.
  • dml: Only DML statements are collected.
  • dcl: Only DCL statements are collected.
  • tcl: Only TCL statements are collected.
  • dql: Only DQL statements are collected.
  • custom: Custom statements are collected.

prefixes

Array of strings

Definition

Prefixes for matching collected SQL statements in the corresponding SQL statement category.

This parameter value varies according to SQL statement categories. The mappings are as follows:

  • all: All SQL statements are collected. This parameter value is as follows:

    [".*"]

  • ddl: Only DDL statements are collected. This parameter value is as follows:

    ["create", "alter", "drop", "truncate", "reindex", "vacuum", "analyze", "declare", "move", "close"]

  • dml: Only DML statements are collected. This parameter value is as follows:

    ["insert", "update", "delete", "merge", "show", "explain", "prepare", "lock", "copy", "execute", "deallocate"]

  • dcl: Only DCL statements are collected. This parameter value is as follows:

    ["grant", "revoke", "reassign", "set"]

  • tcl: Only TCL statements are collected. This parameter value is as follows:

    ["begin", "commit", "rollback", "start", "savepoint", "checkpoint", "release savepoint"]

  • dql: Only DQL statements are collected. This parameter value is as follows:

    ["select"]

  • custom: Custom statements are collected. This parameter value is as follows:

    List of custom SQL statement types when SQL Explorer is enabled.

Range

N/A

is_preset

Boolean

Definition

Whether the SQL statement category is preset.

Range

  • true: The value of category is all, ddl, dml, dcl, tcl, or dql.
  • false: The value of category is custom.

Example Request

Querying SQL Explorer status records

GET https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/4a89780fa1024361bcb855fed6aab89e/instances/0abd10ac1d3e4ab5a56330c304e7da5fin14/full-sql-switches?limit=1000&offset=0

Example Response

{
    "parser": null,
    "total_count": 1,
    "allowed_sql_types": [
        {
            "category": "all",
            "prefixes": [
                ".*"
            ],
            "is_preset": true
        },
        {
            "category": "dml",
            "prefixes": [
                "insert",
                "update",
                "delete",
                "merge",
                "show",
                "explain",
                "prepare",
                "lock",
                "copy",
                "execute",
                "deallocate"
            ],
            "is_preset": true
        },
        {
            "category": "custom",
            "prefixes": [],
            "is_preset": false
        },
        {
            "category": "dcl",
            "prefixes": [
                "grant",
                "revoke",
                "reassign",
                "set"
            ],
            "is_preset": true
        },
        {
            "category": "tcl",
            "prefixes": [
                "begin",
                "commit",
                "rollback",
                "start",
                "savepoint",
                "checkpoint",
                "release savepoint"
            ],
            "is_preset": true
        },
        {
            "category": "ddl",
            "prefixes": [
                "create",
                "alter",
                "drop",
                "truncate",
                "reindex",
                "vacuum",
                "analyze",
                "declare",
                "move",
                "close"
            ],
            "is_preset": true
        },
        {
            "category": "dql",
            "prefixes": [
                "select"
            ],
            "is_preset": true
        }
    ],
    "full_sql_switches": [
        {
            "is_open": true,
            "begin_time": "2025-08-06T16:40:39+0800",
            "end_time": null,
            "online_hours": 0,
            "save_days": 30,
            "save_months": 0,
            "storage_mode": "LTS",
            "storage_device_id": null,
            "lts_config": {
                "log_group_name": "GROUP_GAUSSDB_APS-0abd10ac1d3e4ab5a56330c304e7da5fin14",
                "log_group_id": "a137d930-fa2a-4a7b-9cec-f50e3d69260f",
                "group_log_type": "aps_log",
                "group_ttl_in_days": 30,
                "log_stream_name": "STREAM_APS_FULL_SQL-0abd10ac1d3e4ab5a56330c304e7da5fin14",
                "log_stream_id": "f418b717-9587-4ab2-9c33-56fad6b55ca9",
                "stream_log_type": "full_sql",
                "stream_ttl_in_days": 30,
                "stream_structure_config_id": "\"4a89780fa1024361bcb855fed6aab89e_a137d930-fa2a-4a7b-9cec-f50e3d69260f_f418b717-9587-4ab2-9c33-56fad6b55ca9\"",
                "stream_index_config_id": "f418b717-9587-4ab2-9c33-56fad6b55ca9"
            },
            "sql_type_range": [
                {
                    "category": "all",
                    "prefixes": [
                        ".*"
                    ],
                    "is_preset": true
                }
            ],
            "is_exclude_sys_user": false,
            "file_data_type": null,
            "bind_obs_info": null,
            "parser": null
        }
    ]
}

Status Codes

Error Codes

For details, see Error Codes.