Skip to content

DQL Asynchronous Data Query



POST /api/v1/df/asynchronous/query_data

Overview

Request Body Parameters

Parameter Type Required Description
queries array Multi-command query; its content is a list of query objects. For new queries, do not pass async_id. When polling, pass back the server-returned async_id only for the corresponding query item that is still running.
Allow empty: False
fieldTagDescNeeded boolean Whether field or tag description information is needed.
Allow empty: False

Supplementary Parameter Notes

Query Notes


This interface supports both POST and GET, and both methods use the same JSON object parameter structure: POST sends the complete parameters in the application/json request body; GET passes body=<complete JSON object string> in the query string and URL-encodes it. The top level does not accept string, array, null, number, or boolean.

The final response of an asynchronous query may contain DQLDataAccessScopeRestricted in content.data[i].warnings[]. details[0].metadata.namespace is fixed to logging in the current release. restriction=partial means only data from indexes with permission is returned; restriction=all means no permission for the related log indexes and an empty result is returned. The HTTP status code and request parameters remain unchanged.

async_id Lifecycle (Important)

  1. When initiating a new logical query, you must omit queries[i].async_id. If the server switches to asynchronous execution, it returns content.data[i].is_running=true and a non-empty content.data[i].async_id in the same position.
  2. Only when is_running is strictly true and async_id is non-empty should this ID be used to poll the same task. Polling requests should keep the item's qtype, query, target workspace, and targetRegion unchanged, and put the ID back into the corresponding queries[i].async_id.
  3. When is_running=false, the task has ended. Even if the async_id field still appears in the response structure, the caller must not continue carrying the old ID in the next new query. Both new queries and queries with modified query statements/time ranges must omit async_id again.
  4. async_id belongs to only one query item and one task. It is not a session ID, nor a pagination cursor. In batch queries, content.data[i] corresponds to queries[i] by array index. Do not use the ID of one query item for another query item. To reduce mapping errors, it is recommended to submit only one query per asynchronous call.
  5. If is_running=true but async_id is empty, treat it as an abnormal response that cannot be polled. Do not fill in a historical ID. Record the traceId and re-initiate the logical query with a limited retry policy, or contact technical support.

It is recommended to use incremental backoff and set a total timeout to avoid polling without intervals. After the task completes, if pagination is needed, use search_after, next_cursor_time, or next_cursor_token returned in the final result. Do not use async_id as a substitute for pagination parameters.

First request (without async_id)

{
  "queries": [
    {
      "qtype": "dql",
      "query": {
        "q": "L::re(`.*`):(`message`)",
        "timeRange": [1772516130000, 1772519730000],
        "limit": 100,
        "workspaceUUIDs": ["wksp_target"],
        "targetRegion": "region_code"
      }
    }
  ]
}

Poll the same task only while it is running

{
  "queries": [
    {
      "async_id": "async_task_id_from_content_data_0",
      "qtype": "dql",
      "query": {
        "q": "L::re(`.*`):(`message`)",
        "timeRange": [1772516130000, 1772519730000],
        "limit": 100,
        "workspaceUUIDs": ["wksp_target"],
        "targetRegion": "region_code"
      }
    }
  ]
}

Cross-site queries must also obey the restriction that one request queries only one targetRegion. For information on obtaining the target workspace and site code and the complete call flow, see: OpenAPI Cross-Site Data Query.

  1. Parameter Description
Parameter Type Required Description
queries array Y Multi-command query; its content is a list of query objects
fieldTagDescNeeded boolean Whether field or tag description information is needed
  1. Description of queries[*] Member Parameter Structure

Compared with synchronous queries, each query item additionally supports async_id; it is used only for polling a task that is still running.

Parameter Type Required Description
async_id string N ID of a single asynchronous task. Must be omitted for new queries. Only when the previous result with the same index satisfies content.data[i].is_running=true and content.data[i].async_id is non-empty should this ID be put back into the same queries[i] to continue polling. Stop carrying it immediately after is_running=false. It is forbidden to reuse it for new queries or other query items
qtype string Y Type of query statement
dql: DQL query statement;
promql: PromQL query statement
query json Y Query structure
query.q string Query statement consistent with the qtype type, for example a DQL or PromQL query statement
query.ignore_cache boolean Whether to disable cache; default false, which means cache is used
query.promqlType enum Effective when qtype=promql; optional values are instantQuery and rangeQuery; default is rangeQuery
query.highlight boolean Whether to display highlighted data
query.timeRange array Timestamp list of the time range. The start and end times of DQL / PromQL must use the same unit (seconds, milliseconds, microseconds, or nanoseconds). Mixed usage returns HTTP 400 ft.TimeRangeUnitMismatch. Pagination cursors remain independent
query.disableMultipleField bool Whether to enable single-column mode; default is true
query.showLabel bool Whether to display object labels; default is false
query.funcList array Re-aggregation modifiers on DQL return values; this parameter is invalid when disableMultipleField=false
query.slimit integer Timeline group size, only effective for metric queries
query.soffset integer Timeline group offset
query.limit integer Page size
query.offset integer Page offset
query.orderby array Sort list, structure is {fieldName: method}; Measurement queries support only fieldName=time, and method can be desc or asc
query.sorderby array Sort list; the column of sorderby is an expression and supports all aggregate functions that return a single value: min, max, last, avg, p90, p95, count. Format is {fieldName:method}, same structure as orderby
query.order_by array Sort list, structure is [{"column": "field", "order": "DESC"}], doris engine compatible field
query.sorder_by array Sort list, structure is [{"column": "field", "order": "DESC"}], doris engine compatible field
query.density string Point density of the response; priority is lower than autoDensity and higher than the density set in the DQL statement
query.interval number Time slice interval. Only accepts positive integer milliseconds that fall within the Kodo int64 range and are no less than 1 ms. The default unit is seconds; interval_unit can be used to specify milliseconds
query.interval_unit string Unit of interval; optional values are s and ms; default is s
query.search_after array Pagination marker. Use the search_after value from the previous response with the same parameters as the parameter for this request
query.maxPointCount integer Maximum point count
query.workspaceUUID string UUID of a single authorized workspace to query; * means query all authorized workspaces within targetRegion
query.workspaceUUIDs array List of authorized workspace UUIDs to query; when non-empty, it takes precedence over query.workspaceUUID. The UUIDs in the same list must belong to the same site; ["*"] means query all authorized workspaces within targetRegion. It is recommended not to pass both fields at the same time
query.targetRegion string regionCode of the site to which the authorized workspace belongs; obtain it from the regionCode in the same group as the target workspaceUUID in /wksp_share/granted_ws_list. It is recommended to pass it for explicit cross-site queries and required when querying *; it must not be changed during polling
query.output_format string lineprotocol: line protocol output. If not specified, the existing output format remains unchanged by default
query.cursor_time integer Segmented query threshold: set to end_time for the first segmented query; afterwards pass next_cursor_time from the response
query.cursor_token string Pagination query token (the value of cursor_token returned by the engine). When paginating, set the next_cursor_token returned by the previous query as the cursor_token of the current query. Requests without cursor_token may cause data with the same timestamp to be skipped when paging
query.disable_sampling bool Whether to disable sampling; default is false
query.disable_truncate bool Whether to disable truncation of returned content; default is false, meaning truncation is allowed
  1. Response Point Density density Parameter Values
Value Description
lower Lower, 60 points
low Low, 180 points
medium Medium, 360 points
high High, 720 points

Note the priority of the point density parameter, maximum density density[high] maxPointCount > interval > density > control parameters in the DQL statement

  1. Common Query Notes

  2. Unrecovered Events Query

  3. OpenAPI Cross-Site Data Query

Note: When querying data through the OpenAPI interface, the default role is Administrator. Note that Data Access rules may apply.

Request Example

curl 'https://openapi.guance.com/api/v1/df/asynchronous/query_data' \
-H 'Content-Type: application/json' \
-H 'DF-API-KEY: <DF-API-KEY>' \
--data-raw '{"queries":[{"qtype":"dql","query":{"q":"L::re(`.*`):(`message`)","timeRange":[1772516130000,1772519730000],"limit":100}}]}' \
--compressed

Response

{
    "code": 200,
    "content": {
        "data": [
            {
                "async_id": "async_task_id",
                "is_running": true
            }
        ]
    },
    "errorCode": "",
    "message": "",
    "success": true,
    "traceId": "TRACE-XXXX"
}

Feedback

Is this page helpful?