DQL Data Query (Legacy)¶
POST /api/v1/df/query_data
Overview¶
DQL Data Query
Query Request Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| body | string | DQL query structure Allow empty: False |
|
| queries_body | string | DQL query structure (deprecated as of 2023-08-11) Allow empty: False |
|
| search_after | string | Pagination request parameter (deprecated as of 2023-08-11) Allow empty: False |
Additional Parameter Notes¶
Query Notes
The response content.data[i].warnings[] may contain DQLDataAccessScopeRestricted:
details[0].metadata.namespaceis currently fixed tologging;details[0].metadata.restriction=partialindicates that only data from log indices with permission is returned;details[0].metadata.restriction=allindicates that none of the relevant log indices have data access permissions, and an empty result is returned;-
The HTTP status code remains 200; the warning coexists with existing GuanceDB/Kodo warnings.
-
Query String Element Field Description
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| body | string | Y | Query request body |
| queries_body[*] | string | (Legacy parameter, deprecated as of 2023-08-10) Query list | |
| search_after | string | (Legacy parameter, deprecated as of 2023-08-10; new version moves this parameter to the query structure) Pagination data. Default is [] for the first query. To retrieve more paginated data, include the search_after field from the previous query result. |
- JSON Structure Parameters in
body
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| queries | array | Y | Multi-command query, a list of query objects |
| fieldTagDescNeeded | boolean | Whether field or tag description is needed |
queries[*]Member Parameter Structure
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| qtype | string | Y | Query statement type dql: DQL type query; promql: PromQL type query |
| query | json | Y | Query structure |
| query.q | string | Query statement consistent with the qtype, e.g., a DQL or PromQL query |
|
| query.ignore_cache | boolean | Whether to disable cache for the query. Default is false (use cache). |
|
| query.promqlType | enum | Effective when qtype=promql. PromQL query type, optional values: instantQuery and rangeQuery. Default is rangeQuery. |
|
| query.highlight | boolean | Whether to display highlighted data | |
| query.timeRange | array | Timestamp list for the time range | |
| query.disableMultipleField | bool | Whether to enable single-column mode. Default is true. |
|
| query.showLabel | bool | Whether to display object labels. Default is none. | |
| query.funcList | array | Re-aggregation modifier for DQL return values. Note: this parameter is invalid when disableMultipleField=false. |
|
| query.slimit | integer | Time series grouping size, valid only for metric queries | |
| query.soffset | integer | Time series grouping offset | |
| query.limit | integer | Page size | |
| query.offset | integer | Page offset | |
| query.orderby | array | Sort list: {fieldName:method}. Note: for measurement queries, sorting only supports fieldName=time; method in ["desc", "asc"]. |
|
| query.density | string | Response point density. Priority is lower than autoDensity but higher than the density set in the DQL statement. |
|
| query.interval | number | Time slice interval. Accepts only positive integers that can be converted to Kodo int64 range and are not less than 1ms. Default unit is seconds; can be specified as milliseconds via interval_unit. |
|
| query.interval_unit | string | Unit for interval. Options: s, ms. Default: s. |
|
| query.search_after | array | Pagination token. Pass the pagination token returned by the current API for the next request. | |
| query.maxPointCount | integer | Maximum number of points | |
| query.workspaceUUID | string | UUID of the workspace to query. "*" means query all authorized workspaces. See the workspace reference API: /wksp_share/granted_ws_list. |
|
| query.workspaceUUIDs | array | UUIDs of the workspaces to query. Priority is higher than query.workspaceUUID. ["*"] means query all authorized workspaces. See the workspace reference API: /wksp_share/granted_ws_list. |
|
| query.targetRegion | string | Required when the query workspace is set to ["*"]. |
|
| query.output_format | string | lineprotocol: output as line protocol. If not specified, the current output format is retained. |
|
| query.cursor_time | integer | Segment query threshold: for the first segment query, set cursor_time to end_time; for subsequent segment queries, set cursor_time to the next_cursor_time from the response. |
|
| query.cursor_token | string | Pagination query token (returned by the engine as cursor_token). For pagination, set cursor_token to the next_cursor_token from the previous query. Requests without cursor_token may cause data with the same timestamp to be skipped during pagination. |
|
| query.disable_sampling | bool | Sampling disable switch. Default is false. |
|
| query.disable_truncate | bool | Whether to truncate the query result. Default is none. |
- Response Point Density
densityParameter Values
| Value | Description |
|---|---|
| lower | Lower, 60 points |
| low | Low, 180 points |
| medium | Medium, 360 points |
| high | High, 720 points |
Note on the priority of point density parameters: maxPointCount > interval > density > control parameters in the DQL statement.
-
Common Query Notes
Note: When querying data using the OpenAPI, the default role is Admin. Data access rule restrictions may apply.
Example Request¶
curl 'https://openapi.guance.com/api/v1/df/query_data?body=\{%22queries%22:\[\{%22uuid%22:%2205ea25f0-2fa3-11ee-aa03-57233270ef0c%22,%22qtype%22:%22dql%22,%22query%22:\{%22q%22:%22L::re(`.*`):(`*`)\{+`index`+IN+\[%27default%27\]+\}%22,%22highlight%22:true,%22limit%22:50,%22orderby%22:\[\{%22time%22:%22desc%22\}\],%22_funcList%22:\[\],%22funcList%22:\[\],%22disableMultipleField%22:false,%22align_time%22:false,%22is_optimized%22:true,%22offset%22:0,%22search_after%22:\[1690808645037,538070,%22L_1690808645037_cj3r2itnel8fnfu5tlag%22\],%22timeRange%22:\[1690807857000,1690808757999\],%22tz%22:%22Asia/Shanghai%22\}\}\],%22expensiveQueryCheck%22:true\}' \
-H 'DF-API-KEY: <DF-API-KEY>' \
--compressed
Response¶
{
"code": 200,
"content": {
"data": [
{
"AsyncTaskPayload": null,
"async_id": "",
"column_names": [
"container_id",
"source",
"filepath",
"image",
"index",
"df_metering_size",
"__namespace",
"host",
"log_read_offset",
"__docid",
"filename",
"service",
"image_name",
"image_short_name",
"image_tag",
"log_read_lines",
"message",
"log_read_time",
"container_name",
"container_type",
"message_length",
"create_time",
"container_runtime_name",
"date_ns",
"status"
],
"complete": false,
"cost": "19ms",
"index_name": "",
"index_names": "",
"index_store_type": "es",
"is_running": false,
"points": null,
"query_type": "",
"raw_query": "{\\\"aggs\\\":{},\\\"_source\\\":{\\\"excludes\\\":[\\\"message@json\\\"],\\\"includes\\\":[]},\\\"query\\\":{\\\"bool\\\":{\\\"filter\\\":[{\\\"term\\\":{\\\"__namespace\\\":\\\"logging\\\"}},{\\\"range\\\":{\\\"date\\\":{\\\"gte\\\":\\\"1680187562081\\\",\\\"lte\\\":\\\"1680230762081\\\"}}},{\\\"bool\\\":{\\\"should\\\":[{\\\"terms\\\":{\\\"index\\\":[\\\"default\\\"]}}]}}]}},\\\"size\\\":50,\\\"sort\\\":[{\\\"date\\\":{\\\"missing\\\":\\\"_last\\\",\\\"order\\\":\\\"desc\\\",\\\"unmapped_type\\\":\\\"long\\\"}},{\\\"date_ns\\\":{\\\"missing\\\":\\\"_last\\\",\\\"order\\\":\\\"desc\\\",\\\"unmapped_type\\\":\\\"long\\\"}},{\\\"__docid\\\":{\\\"missing\\\":\\\"_first\\\",\\\"order\\\":\\\"desc\\\",\\\"unmapped_type\\\":\\\"string\\\"}}],\\\"search_after\\\":[1680226330509,8572,\\\"L_1680226330509_cgj4hqbrhi85kl1m6os0\\\"],\\\"timeout\\\":\\\"54s\\\"}",
"search_after": [
1680226330508,
82936,
"L_1680226330508_cgj4hbdepb7fcn07sf60"
],
"series": [
{
"columns": [
"container_id",
"time",
"source",
"filepath",
"image",
"index",
"df_metering_size",
"__namespace",
"host",
"log_read_offset",
"__docid",
"filename",
"service",
"image_name",
"image_short_name",
"image_tag",
"log_read_lines",
"message",
"log_read_time",
"container_name",
"container_type",
"message_length",
"create_time",
"container_runtime_name",
"date_ns",
"status"
],
"values": [
[
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380",
1680226330509,
"test",
"/var/lib/docker/containers/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test:test",
"default",
1,
"logging",
"izbp152ke14timzud0du15z",
149232879,
"L_1680226330509_cgj4hqbrhi85kl1m6org",
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test",
"test",
"test",
"test",
147890,
"ddtrace.profiling.exporter.http.UploadFailed: [Errno 101] Network is unreachable",
1680226330508872700,
"compose_python_ddtrace_web_b_1",
"docker",
80,
1680230633485,
"compose_python_ddtrace_web_b_1",
8571,
"unknown"
],
[
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380",
1680226330509,
"test",
"/var/lib/docker/containers/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test:test",
"default",
1,
"logging",
"izbp152ke14timzud0du15z",
149232879,
"L_1680226330509_cgj4hqbrhi85kl1m6or0",
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test",
"test",
"test",
"test",
147889,
" raise retry_exc from fut.exception()",
1680226330508872700,
"compose_python_ddtrace_web_b_1",
"docker",
40,
1680230633485,
"compose_python_ddtrace_web_b_1",
8570,
"unknown"
],
[
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380",
1680226330509,
"test",
"/var/lib/docker/containers/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test:test",
"default",
1,
"logging",
"izbp152ke14timzud0du15z",
149232879,
"L_1680226330509_cgj4hqbrhi85kl1m6oqg",
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test",
"test",
"test",
"test",
147888,
" File \\\"/usr/local/lib/python3.7/site-packages/tenacity/__init__.py\\\", line 361, in iter",
1680226330508872700,
"compose_python_ddtrace_web_b_1",
"docker",
87,
1680230633485,
"compose_python_ddtrace_web_b_1",
8569,
"unknown"
],
[
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380",
1680226330508,
"test",
"/var/lib/docker/containers/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380/2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test:test",
"default",
1,
"logging",
"izbp152ke14timzud0du15z",
149228783,
"L_1680226330508_cgj4hbdepb7fcn07sf60",
"2fef685801c80b5cb7d04b7b5e859007de94752aadbe801df812a058acf5e380-json.log",
"test",
"test",
"test",
"test",
147841,
"KeyError: 'dd.service'",
1680226330507918000,
"compose_python_ddtrace_web_b_1",
"docker",
22,
1680230573234,
"compose_python_ddtrace_web_b_1",
82936,
"unknown"
]
]
}
],
"total_hits": 10000
}
]
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "TRACE-CD50CBBD-E29B-4F58-BD6B-618EED50920A"
}