Querying the SQL List
Function
This API is used to query the real-time SQL list.
Calling Method
For details, see Calling APIs.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
URI
POST /v2/{project_id}/clusters/{cluster_id}/dms/queries
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| project_id | Yes | String | Definition Project ID. To obtain the value, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
| cluster_id | Yes | String | Definition Cluster ID. For details about how to obtain the value, see Obtaining the Cluster ID. Constraints The value must be a valid DWS cluster ID. Range It is a 36-digit UUID. Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| cluster_id | Yes | String | Definition Cluster ID. For details about how to obtain the value, see Obtaining the Cluster ID. Constraints The value must be a valid DWS cluster ID. Range It is a 36-digit UUID. Default Value N/A |
| project_id | Yes | String | Definition Project ID. To obtain the value, see Obtaining a Project ID. Constraints N/A Range N/A Default Value N/A |
| offset | Yes | String | Definition Offset. The query starts from the offset. Generally, the value is the number of pages minus 1. Range Greater than or equal to 0 |
| limit | Yes | String | Definition Number of records displayed on each page. Range Greater than 0 |
| conditions | Yes | Array of ListQueriesCondition objects | Definition Search criteria. Range N/A |
| order_by | No | String | Definition Sorting field. Range N/A |
| target | Yes | String | Definition Its fixed value is db_queries. Range N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| field | Yes | String | Definition Field name. Range systemQuery: whether to hide system queries. userName: username. applicationName: application name. dbname: database name. resourcePool: resource pool. queryStatus: query status. enqueue: queue status. |
| value | Yes | String | Definition Field value. Range N/A |
| operator | Yes | String | Definition Comparison mode. Range String type: =, !=, like, and not like Integer type: =, !=, >, <, >=, <= Boolean type: = and != |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Definition Response code. Range N/A |
| msg | String | Definition Response information. Range N/A |
| data | ListQueriesData object | Definition Response data. Range N/A |
| count | Integer | Definition Total number of records. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| queries | Array of ListQueriesDto objects | Definition Queried data list. Range N/A |
| status | ListQueriesStatus object | Definition Statistics. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| average_query_waiting_time | Double | Definition Average query wait time. Range N/A |
| average_time_consumption_of_queries | Double | Definition Average query duration. Range N/A |
| average_time_consumption_of_sessions | Double | Definition Average session duration. Range N/A |
| queries_count | Long | Definition Number of queries. Range N/A |
| session_count | Long | Definition Number of sessions. Range N/A |
Example Requests
POST https://{Endpoint}/v2/{project_id}/clusters/{cluster_id}/dms/queries
{
"offset" : "0",
"limit" : "1",
"cluster_id" : "6aa82ba1-fc97-4838-9b61-3e8da13e2fe9",
"project_id" : "g6aa82ba1fc9748389b613e8da13e2fe9",
"conditions" : [ {
"field" : "userName",
"value" : "dbadmin",
"operator" : "="
}, {
"field" : "applicationName",
"value" : "app",
"operator" : "<>"
}, {
"field" : "dbName",
"value" : "dbadmin",
"operator" : "="
}, {
"field" : "resourcePool",
"value" : "pool",
"operator" : "<>"
}, {
"field" : "queryStatus",
"value" : "",
"operator" : "="
}, {
"field" : "enqueue",
"value" : "",
"operator" : "<>"
}, {
"field" : "lane",
"value" : "",
"operator" : "="
}, {
"field" : "instName",
"value" : "cn-1-1",
"operator" : "<>"
}, {
"field" : "pid",
"value" : "33",
"operator" : "="
}, {
"field" : "blockTime",
"value" : "1",
"operator" : "="
}, {
"field" : "duration",
"value" : "2",
"operator" : "<>"
}, {
"field" : "minCpuTime",
"value" : "3",
"operator" : ">"
}, {
"field" : "maxCpuTime",
"value" : "4",
"operator" : "<"
}, {
"field" : "totalCpuTime",
"value" : "5",
"operator" : ">="
}, {
"field" : "cpuSkewPercent",
"value" : "6",
"operator" : "<="
}, {
"field" : "spillInfo",
"value" : "DN spill information",
"operator" : "="
}, {
"field" : "minSpillSize",
"value" : "7",
"operator" : "<>"
}, {
"field" : "maxSpillSize",
"value" : "8",
"operator" : ">"
}, {
"field" : "averageSpillSize",
"value" : "9",
"operator" : "<"
}, {
"field" : "spillSkewPercent",
"value" : "10",
"operator" : ">="
}, {
"field" : "queryBand",
"value" : "Job type",
"operator" : "<>"
}, {
"field" : "jobName",
"value" : "Task name",
"operator" : "="
}, {
"field" : "jobInst",
"value" : "Task instance",
"operator" : "<>"
}, {
"field" : "clientHostname",
"value" : "Server name",
"operator" : "="
}, {
"field" : "clientPort",
"value" : "TCP port",
"operator" : "<>"
}, {
"field" : "waiting",
"value" : "Waiting or not",
"operator" : "="
}, {
"field" : "estimateTotalTime",
"value" : "11",
"operator" : "="
}, {
"field" : "estimateLeftTime",
"value" : "12",
"operator" : "<>"
}, {
"field" : "controlGroup",
"value" : "cgroup",
"operator" : "like"
}, {
"field" : "minPeakMemory",
"value" : "13",
"operator" : "="
}, {
"field" : "maxPeakMemory",
"value" : "14",
"operator" : "<>"
}, {
"field" : "averagePeakMemory",
"value" : "15",
"operator" : ">"
}, {
"field" : "memorySkewPercent",
"value" : "16",
"operator" : "<"
}, {
"field" : "estimateMemory",
"value" : "17",
"operator" : ">="
}, {
"field" : "minDnTime",
"value" : "18",
"operator" : "<="
}, {
"field" : "maxDnTime",
"value" : "19",
"operator" : "="
}, {
"field" : "averageDnTime",
"value" : "20",
"operator" : "<>"
}, {
"field" : "dntimeSkewPercent",
"value" : "21",
"operator" : ">"
}, {
"field" : "warning",
"value" : "Alarm",
"operator" : "="
}, {
"field" : "averagePeakIops",
"value" : "22",
"operator" : "<>"
}, {
"field" : "iopsSkewPercent",
"value" : "23",
"operator" : ">"
}, {
"field" : "wlmStatus",
"value" : "Statement status",
"operator" : "="
}, {
"field" : "wlmAttrib",
"value" : "Statement attribute",
"operator" : "not like"
} ],
"order_by" : "duration asc",
"target" : "db_queries"
} Example Responses
Status code: 200
Query succeeded.
{
"code" : 0,
"msg" : "OK",
"count" : 1,
"data" : {
"queries" : [ {
"ctime" : 1699062726000,
"pid" : "140535026615872",
"waiting" : false,
"duration" : 0,
"enqueue" : "",
"warning" : "",
"query" : "WLM fetch collect info from data nodes",
"lane" : "fast",
"priority" : null,
"virtual_cluster_id" : 0,
"inst_name" : "cn_5002",
"db_name" : "postgres",
"query_id" : "145522562959854219",
"query_band" : "",
"job_name" : "",
"job_inst" : "",
"user_name" : "Ruby",
"application_name" : "workload",
"client_address" : "",
"client_hostname" : "",
"client_port" : "",
"start_time" : 0,
"block_time" : 0,
"estimate_total_time" : 0,
"estimate_left_time" : 0,
"resource_pool" : "default_pool",
"control_group" : "",
"min_peak_memory" : 0,
"max_peak_memory" : 0,
"average_peak_memory" : 0,
"memory_skew_percent" : 0,
"estimate_memory" : 0,
"spill_info" : "",
"min_spill_size" : 0,
"max_spill_size" : 0,
"average_spill_size" : 0,
"spill_skew_percent" : 0,
"min_dn_time" : 0,
"max_dn_time" : 0,
"average_dn_time" : 0,
"dntime_skew_percent" : 0,
"min_cpu_time" : 0,
"max_cpu_time" : 0,
"total_cpu_time" : 0,
"cpu_skew_percent" : 0,
"average_peak_iops" : 0,
"iops_skew_percent" : 0,
"max_peak_iops" : 0,
"min_peak_iops" : 0,
"query_plan" : null,
"query_status" : "active",
"wlm_status" : "active",
"wlm_attrib" : "ordinary",
"system_query" : true,
"backend_start" : 1698998138,
"elapsed_time" : 64585,
"curr_xact_start" : 1699062726,
"state_change" : 1698998142,
"query_start" : 1698998142,
"query_elapsed_time" : -1
} ],
"status" : {
"session_count" : 19,
"average_time_consumption_of_sessions" : 51297.58,
"queries_count" : 19,
"average_time_consumption_of_queries" : 48799.8,
"average_query_waiting_time" : 0
}
}
} SDK Sample Code
The SDK sample code is as follows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.dws.v2.region.DwsRegion; import com.huaweicloud.sdk.dws.v2.*; import com.huaweicloud.sdk.dws.v2.model.*; import java.util.List; import java.util.ArrayList; public class ListQueriesSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); DwsClient client = DwsClient.newBuilder() .withCredential(auth) .withRegion(DwsRegion.valueOf("<YOUR REGION>")) .build(); ListQueriesRequest request = new ListQueriesRequest(); request.withClusterId("{cluster_id}"); ListQueriesRequestBody body = new ListQueriesRequestBody(); List<ListQueriesCondition> listbodyConditions = new ArrayList<>(); listbodyConditions.add( new ListQueriesCondition() .withField("userName") .withValue("dbadmin") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("applicationName") .withValue("app") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("dbName") .withValue("dbadmin") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("resourcePool") .withValue("pool") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("queryStatus") .withValue("") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("enqueue") .withValue("") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("lane") .withValue("") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("instName") .withValue("cn-1-1") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("pid") .withValue("33") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("blockTime") .withValue("1") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("duration") .withValue("2") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("minCpuTime") .withValue("3") .withOperator(">") ); listbodyConditions.add( new ListQueriesCondition() .withField("maxCpuTime") .withValue("4") .withOperator("<") ); listbodyConditions.add( new ListQueriesCondition() .withField("totalCpuTime") .withValue("5") .withOperator(">=") ); listbodyConditions.add( new ListQueriesCondition() .withField("cpuSkewPercent") .withValue("6") .withOperator("<=") ); listbodyConditions.add( new ListQueriesCondition() .withField("spillInfo") .withValue("DN spill information") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("minSpillSize") .withValue("7") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("maxSpillSize") .withValue("8") .withOperator(">") ); listbodyConditions.add( new ListQueriesCondition() .withField("averageSpillSize") .withValue("9") .withOperator("<") ); listbodyConditions.add( new ListQueriesCondition() .withField("spillSkewPercent") .withValue("10") .withOperator(">=") ); listbodyConditions.add( new ListQueriesCondition() .withField("queryBand") .withValue("Job type") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("jobName") .withValue("Task name") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("jobInst") .withValue("Task instance") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("clientHostname") .withValue("Server name") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("clientPort") .withValue("TCP port") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("waiting") .withValue("Waiting or not") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("estimateTotalTime") .withValue("11") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("estimateLeftTime") .withValue("12") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("controlGroup") .withValue("cgroup") .withOperator("like") ); listbodyConditions.add( new ListQueriesCondition() .withField("minPeakMemory") .withValue("13") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("maxPeakMemory") .withValue("14") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("averagePeakMemory") .withValue("15") .withOperator(">") ); listbodyConditions.add( new ListQueriesCondition() .withField("memorySkewPercent") .withValue("16") .withOperator("<") ); listbodyConditions.add( new ListQueriesCondition() .withField("estimateMemory") .withValue("17") .withOperator(">=") ); listbodyConditions.add( new ListQueriesCondition() .withField("minDnTime") .withValue("18") .withOperator("<=") ); listbodyConditions.add( new ListQueriesCondition() .withField("maxDnTime") .withValue("19") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("averageDnTime") .withValue("20") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("dntimeSkewPercent") .withValue("21") .withOperator(">") ); listbodyConditions.add( new ListQueriesCondition() .withField("warning") .withValue("Alarm") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("averagePeakIops") .withValue("22") .withOperator("<>") ); listbodyConditions.add( new ListQueriesCondition() .withField("iopsSkewPercent") .withValue("23") .withOperator(">") ); listbodyConditions.add( new ListQueriesCondition() .withField("wlmStatus") .withValue("Statement status") .withOperator("=") ); listbodyConditions.add( new ListQueriesCondition() .withField("wlmAttrib") .withValue("Statement attribute") .withOperator("not like") ); body.withTarget("db_queries"); body.withOrderBy("duration asc"); body.withConditions(listbodyConditions); body.withLimit("1"); body.withOffset("0"); body.withProjectId("g6aa82ba1fc9748389b613e8da13e2fe9"); body.withClusterId("6aa82ba1-fc97-4838-9b61-3e8da13e2fe9"); request.withBody(body); try { ListQueriesResponse response = client.listQueries(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | # coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdkdws.v2.region.dws_region import DwsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdkdws.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = DwsClient.new_builder() \ .with_credentials(credentials) \ .with_region(DwsRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListQueriesRequest() request.cluster_id = "{cluster_id}" listConditionsbody = [ ListQueriesCondition( field="userName", value="dbadmin", operator="=" ), ListQueriesCondition( field="applicationName", value="app", operator="<>" ), ListQueriesCondition( field="dbName", value="dbadmin", operator="=" ), ListQueriesCondition( field="resourcePool", value="pool", operator="<>" ), ListQueriesCondition( field="queryStatus", value="", operator="=" ), ListQueriesCondition( field="enqueue", value="", operator="<>" ), ListQueriesCondition( field="lane", value="", operator="=" ), ListQueriesCondition( field="instName", value="cn-1-1", operator="<>" ), ListQueriesCondition( field="pid", value="33", operator="=" ), ListQueriesCondition( field="blockTime", value="1", operator="=" ), ListQueriesCondition( field="duration", value="2", operator="<>" ), ListQueriesCondition( field="minCpuTime", value="3", operator=">" ), ListQueriesCondition( field="maxCpuTime", value="4", operator="<" ), ListQueriesCondition( field="totalCpuTime", value="5", operator=">=" ), ListQueriesCondition( field="cpuSkewPercent", value="6", operator="<=" ), ListQueriesCondition( field="spillInfo", value="DN spill information", operator="=" ), ListQueriesCondition( field="minSpillSize", value="7", operator="<>" ), ListQueriesCondition( field="maxSpillSize", value="8", operator=">" ), ListQueriesCondition( field="averageSpillSize", value="9", operator="<" ), ListQueriesCondition( field="spillSkewPercent", value="10", operator=">=" ), ListQueriesCondition( field="queryBand", value="Job type", operator="<>" ), ListQueriesCondition( field="jobName", value="Task name", operator="=" ), ListQueriesCondition( field="jobInst", value="Task instance", operator="<>" ), ListQueriesCondition( field="clientHostname", value="Server name", operator="=" ), ListQueriesCondition( field="clientPort", value="TCP port", operator="<>" ), ListQueriesCondition( field="waiting", value="Waiting or not", operator="=" ), ListQueriesCondition( field="estimateTotalTime", value="11", operator="=" ), ListQueriesCondition( field="estimateLeftTime", value="12", operator="<>" ), ListQueriesCondition( field="controlGroup", value="cgroup", operator="like" ), ListQueriesCondition( field="minPeakMemory", value="13", operator="=" ), ListQueriesCondition( field="maxPeakMemory", value="14", operator="<>" ), ListQueriesCondition( field="averagePeakMemory", value="15", operator=">" ), ListQueriesCondition( field="memorySkewPercent", value="16", operator="<" ), ListQueriesCondition( field="estimateMemory", value="17", operator=">=" ), ListQueriesCondition( field="minDnTime", value="18", operator="<=" ), ListQueriesCondition( field="maxDnTime", value="19", operator="=" ), ListQueriesCondition( field="averageDnTime", value="20", operator="<>" ), ListQueriesCondition( field="dntimeSkewPercent", value="21", operator=">" ), ListQueriesCondition( field="warning", value="Alarm", operator="=" ), ListQueriesCondition( field="averagePeakIops", value="22", operator="<>" ), ListQueriesCondition( field="iopsSkewPercent", value="23", operator=">" ), ListQueriesCondition( field="wlmStatus", value="Statement status", operator="=" ), ListQueriesCondition( field="wlmAttrib", value="Statement attribute", operator="not like" ) ] request.body = ListQueriesRequestBody( target="db_queries", order_by="duration asc", conditions=listConditionsbody, limit="1", offset="0", project_id="g6aa82ba1fc9748389b613e8da13e2fe9", cluster_id="6aa82ba1-fc97-4838-9b61-3e8da13e2fe9" ) response = client.list_queries(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth, err := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). SafeBuild() if err != nil { fmt.Println(err) return } hcClient, err := dws.DwsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). SafeBuild() if err != nil { fmt.Println(err) return } client := dws.NewDwsClient(hcClient) request := &model.ListQueriesRequest{} request.ClusterId = "{cluster_id}" var listConditionsbody = []model.ListQueriesCondition{ { Field: "userName", Value: "dbadmin", Operator: "=", }, { Field: "applicationName", Value: "app", Operator: "<>", }, { Field: "dbName", Value: "dbadmin", Operator: "=", }, { Field: "resourcePool", Value: "pool", Operator: "<>", }, { Field: "queryStatus", Value: "", Operator: "=", }, { Field: "enqueue", Value: "", Operator: "<>", }, { Field: "lane", Value: "", Operator: "=", }, { Field: "instName", Value: "cn-1-1", Operator: "<>", }, { Field: "pid", Value: "33", Operator: "=", }, { Field: "blockTime", Value: "1", Operator: "=", }, { Field: "duration", Value: "2", Operator: "<>", }, { Field: "minCpuTime", Value: "3", Operator: ">", }, { Field: "maxCpuTime", Value: "4", Operator: "<", }, { Field: "totalCpuTime", Value: "5", Operator: ">=", }, { Field: "cpuSkewPercent", Value: "6", Operator: "<=", }, { Field: "spillInfo", Value: "DN spill information", Operator: "=", }, { Field: "minSpillSize", Value: "7", Operator: "<>", }, { Field: "maxSpillSize", Value: "8", Operator: ">", }, { Field: "averageSpillSize", Value: "9", Operator: "<", }, { Field: "spillSkewPercent", Value: "10", Operator: ">=", }, { Field: "queryBand", Value: "Job type", Operator: "<>", }, { Field: "jobName", Value: "Task name", Operator: "=", }, { Field: "jobInst", Value: "Task instance", Operator: "<>", }, { Field: "clientHostname", Value: "Server name", Operator: "=", }, { Field: "clientPort", Value: "TCP port", Operator: "<>", }, { Field: "waiting", Value: "Waiting or not", Operator: "=", }, { Field: "estimateTotalTime", Value: "11", Operator: "=", }, { Field: "estimateLeftTime", Value: "12", Operator: "<>", }, { Field: "controlGroup", Value: "cgroup", Operator: "like", }, { Field: "minPeakMemory", Value: "13", Operator: "=", }, { Field: "maxPeakMemory", Value: "14", Operator: "<>", }, { Field: "averagePeakMemory", Value: "15", Operator: ">", }, { Field: "memorySkewPercent", Value: "16", Operator: "<", }, { Field: "estimateMemory", Value: "17", Operator: ">=", }, { Field: "minDnTime", Value: "18", Operator: "<=", }, { Field: "maxDnTime", Value: "19", Operator: "=", }, { Field: "averageDnTime", Value: "20", Operator: "<>", }, { Field: "dntimeSkewPercent", Value: "21", Operator: ">", }, { Field: "warning", Value: "Alarm", Operator: "=", }, { Field: "averagePeakIops", Value: "22", Operator: "<>", }, { Field: "iopsSkewPercent", Value: "23", Operator: ">", }, { Field: "wlmStatus", Value: "Statement status", Operator: "=", }, { Field: "wlmAttrib", Value: "Statement attribute", Operator: "not like", }, } orderByListQueriesRequestBody:= "duration asc" request.Body = &model.ListQueriesRequestBody{ Target: "db_queries", OrderBy: &orderByListQueriesRequestBody, Conditions: listConditionsbody, Limit: "1", Offset: "0", ProjectId: "g6aa82ba1fc9748389b613e8da13e2fe9", ClusterId: "6aa82ba1-fc97-4838-9b61-3e8da13e2fe9", } response, err := client.ListQueries(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.
Status Codes
| Status Code | Description |
|---|---|
| 200 | Query succeeded. |
| 400 | Request error. |
| 401 | Authentication failed. |
| 403 | You do not have required permissions. |
| 404 | No resources found. |
| 500 | Internal server error. |
| 503 | Service unavailable. |
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot