Skip to content

DQL Data Query (Legacy)



POST /api/v1/df/query_data
GET /api/v1/df/query_data

Overview

Retrieve DQL or PromQL data by query batch. This endpoint is compatible with legacy GET and POST calls.

Before Calling and Usage Steps

GET places the JSON object in a URL-encoded body, while POST can submit JSON directly. Legacy GET prioritizes a non-empty queries_body and recognizes top-level search_after only on that path. The existing POST single-query format can use top-level qtype and query. For new client integrations, use Query v1.

Replace the Measurement and fields in the examples with data collected in the Workspace; you can obtain them from the Measurement List and Measurement Schema. Replace the time range with the period in which the data resides. When parsing the response, check warnings or query_error for each item, and use each item's own cursor for subsequent pages.

Request Headers

Parameter Name Type Required Description
DF-API-KEY string Y OpenAPI Key of the current Workspace.
Example: <DF-API-KEY>
How to obtain or enter: Obtain credentials with query permissions from API Key management in the target Workspace.

Query Request Parameters

Parameter Name Type Required Description
body string Conditionally required Complete query JSON object string.
Null allowed: False
Example: {"queries":[{"qtype":"dql","query":{"q":"M::`cpu`:(`usage_idle`)","timeRange":[1785427200000,1785430800000],"limit":5}}]}
How to obtain or enter: Serialize the query object once, then URL-encode it, for example with curl --data-urlencode.
queries_body string Conditionally required When non-empty, takes precedence over body; for legacy client compatibility.
Null allowed: False
Example: {"queries":[{"qtype":"dql","query":{"q":"M::`cpu`:(`usage_idle`)","timeRange":[1785427200000,1785430800000],"limit":5}}]}
How to obtain or enter: Serialize the object containing queries and submit it with curl --data-urlencode.
search_after string Read only on the queries_body path; omit for the first query.
Null allowed: False
Example: [1785427200000,"cursor-example"]
How to obtain or enter: JSON-serialize and URL-encode the array actually returned by the previous page of the same query.

Additional Parameter Notes

Query Description


This endpoint is a legacy compatibility entry point. For new integrations, use POST /api/v1/df/query_data_v1; legacy GET continues to pass parameters using body=<URL-encoded JSON>. Do not double-encode the JSON.

This endpoint supports both POST and GET, and both methods support the batch query object below:

  • POST: The complete parameters are passed as an application/json request body.
  • GET: Do not use the HTTP entity body; pass parameters in the query string via body=<complete JSON object string>. The client should URL-encode the body parameter.
  • The top level must be a JSON object. A double JSON-encoded string, array, null, number, or boolean is not accepted.

For cross-Workspace/cross-site queries, all queries[*] in a request can only target the same targetRegion. To query multiple sites, split requests by site and merge the results on the client. Obtain the target Workspace and targetRegion through /api/v1/wksp_share/granted_ws_list. For details, see OpenAPI Cross-Site Data Query.

The response content.data[i].warnings[] may contain DQLDataAccessScopeRestricted:

  • details[0].metadata.namespace is fixed to logging in this release.
  • details[0].metadata.restriction=partial indicates that only data from Log Indexes with permissions is returned.
  • details[0].metadata.restriction=all indicates that none of the related Log Indexes have Data Access permissions and an empty result is returned.
  • The HTTP status code remains 200, and the warning coexists with existing GuanceDB/Kodo warnings.

  • Query String Element Field Descriptions

Parameter Name type Required Description
body string Either body or queries_body Query request body
queries_body string Either body or queries_body (Compatibility parameter) JSON object string containing the queries array
search_after string (Compatibility parameter, only for queries_body) Paginated query data. Omit for the first query. To query more pages, add the search_after field from the previous query result to query subsequent data.

body and the compatibility parameter queries_body are both conditionally required. For GET, provide at least one non-empty and valid JSON object; if both are provided, the non-empty queries_body takes precedence.

  1. JSON Object for a Standard Batch Query
Parameter Name 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 required
  1. queries[*] Member Parameter Structure
Parameter Name type Required Description
qtype string Default: dql. Type of query statement.
dql: DQL query statement.
promql: PromQL query statement. Example: dql.
query json Y Query structure. Example: {"q":"M::`cpu`:(`usage_idle`)","timeRange":[1785427200000,1785430800000],"limit":5}.
query.q string Query statement consistent with the qtype type, such as a dql or promql query statement. Example: M::`cpu`:(`usage_idle`). Copy the statement from the query tool, or spell it according to the field names in the Measurement Schema/Log Schema.
query.ignore_cache boolean Whether to disable caching. Default: false, which means caching is used. Example: false.
query.disable_streaming_aggregation boolean Whether to disable streaming aggregation. Default: false; explicitly passing true disables it, and explicitly passing false allows it. Example: false.
query.promqlType enum Takes effect when qtype=promql. Valid values: instantQuery, rangeQuery; default: rangeQuery. Example: rangeQuery.
query.highlight boolean Whether to display highlighted data. Example: false.
query.timeRange array List of timestamps for the time range; the start and end times of DQL / PromQL must use the same unit (seconds, milliseconds, microseconds, or nanoseconds). Mixing units returns HTTP 400 ft.TimeRangeUnitMismatch; pagination cursors remain independent. Example: [1785427200000,1785430800000]. Replace the required query window with two timestamps of the same precision; Unix milliseconds are recommended.
query.disableMultipleField bool Whether to enable single-column mode. Default: true. Example: true.
query.showLabel bool Whether to display the object's labels. Default: false. Example: false.
query.funcList array Re-aggregate and modify DQL return values; process according to the selected aggregate function. Example: ["last"].
query.slimit integer Time Series grouping size; valid only for metric queries. Example: 10.
query.soffset integer Time Series grouping offset. Example: 10.
query.limit integer Pagination size. Example: 5.
query.offset integer Pagination offset. Example: 5.
query.orderby array Sort list, structured as {fieldName: method}; Measurement queries support only fieldName=time, and method can be desc or asc. Example: [{"time":"desc"}].
query.density string Point density of the response. Its priority is lower than autoDensity and higher than the density set in the dql statement. Example: medium.
query.interval number Time slice interval. Only accepts positive numbers that can be converted to an integer number of milliseconds within the Kodo int64 range and are not less than 1 ms; the default unit is seconds, and interval_unit can specify milliseconds. Example: 60.
query.interval_unit string Unit of interval. Valid values: s, ms; default: s. Example: s.
query.search_after array Pagination marker returned by the current endpoint, to be passed in the next request. Example: [1785427200000,"cursor-example"]. For subsequent pages, you must copy the array actually returned by the previous identical query.
query.maxPointCount integer Maximum number of points. Example: 360.
query.workspaceUUID string UUID of a single authorizing Workspace to query; * means query all authorized Workspaces in targetRegion. Example: wksp_example.
query.workspaceUUIDs array List of authorizing Workspace UUIDs to query; when non-empty, takes precedence over query.workspaceUUID. The same list must belong to the same site; ["*"] means query all authorized Workspaces in targetRegion. Do not pass both fields at the same time. Example: ["wksp_example"].
query.targetRegion string The regionCode of the site to which the authorizing Workspace belongs; obtain it from the regionCode in the same group as the target workspaceUUID in /wksp_share/granted_ws_list. For explicit cross-site queries, pass the authorizer's regionCode; when using a wildcard and omitting it, query the current site. Example: example-region.
query.output_format string lineprotocol: line protocol output. If not specified, the existing output format remains unchanged by default. Example: lineprotocol.
query.cursor_time integer Segmented query threshold: set to end_time for the first segmented query; afterward, pass the next_cursor_time from the response. Example: 1785430800000. For subsequent pages, use next_cursor_time from the response.
query.cursor_token string Pagination query token (the cursor_token value returned by the engine): for pagination queries, set the next_cursor_token returned by the previous query as the cursor_token for the current query; requests without cursor_token may cause data with the same timestamp to be skipped when paging. Example: cursor-example. For subsequent pages, use next_cursor_token from the response.
query.disable_sampling bool Sampling disable switch. Default: false. Example: false.
query.disable_truncate bool Whether to disable truncation of returned content. Default: false, which means truncation is allowed. Example: false.
  1. Response Point Density density Parameter Values
Valid 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] * interval takes precedence over density and the point density settings in DQL. maxPointCount can further limit the derived number of points.

  • Common Query Notes

  • Unrecovered Events Query

  • OpenAPI Cross-Site Data Query

Data visibility depends on the effective permissions of the API Key, Workspace authorization, and Data Access rules.

Request Examples

curl --get 'https://openapi.guance.com/api/v1/df/query_data' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  --data-urlencode 'body={"queries":[{"qtype":"dql","query":{"q":"M::`cpu`:(`usage_idle`)","timeRange":[1785427200000,1785430800000],"limit":5}}]}'

Example of a legacy client using queries_body

curl --get 'https://openapi.guance.com/api/v1/df/query_data' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  --data-urlencode 'queries_body={"queries":[{"qtype":"dql","query":{"q":"M::`cpu`:(`usage_idle`)","timeRange":[1785427200000,1785430800000],"limit":5}}]}'

Response

HTTP 200, application/json. Read results and errors by query item.

Field Type Description
content.data array<object> Batch results returned by the query. Parse by query item.
content.data[].series array<object> Data series. Can be empty when there is no data or the query item fails.
content.data[].series[].columns array<string> Column names of the series.
content.data[].series[].values array Result rows in columns order.
content.data[].series[].name string Series name returned according to the engine and query type.
content.data[].series[].units array Units returned in columns order; elements can be strings or null. The field may be omitted.
content.data[].series[].tags object Grouping information may be returned when grouping by tags.
content.data[].column_names array<string> Some engines provide column names separately.
content.data[].complete boolean Whether the engine reports the result as complete.
content.data[].is_running boolean Whether the query item is still running.
content.data[].search_after array Legacy segmented pagination cursor. Use only for subsequent pages of the same query.
content.data[].next_cursor_time integer New cursor time. A negative value indicates that there are no more records.
content.data[].next_cursor_token string Token associated with the new cursor; can be empty.
content.data[].warnings array<object> Query warnings. HTTP 200 may still be returned when some indexes are restricted.
content.data[].query_error object Error object for an individual query item; may appear together with HTTP 200.
content.data[].query_error.errorCode string Individual error identifier.
content.data[].query_error.errorType integer Error type returned by the standard DQL query engine, provided according to the actual response.
content.data[].query_error.error string Text provided for some standard DQL errors.
content.declaration object or null Workspace declaration.
{
  "code": 200,
  "content": {
    "data": [
      {
        "column_names": [
          "time",
          "usage_idle"
        ],
        "complete": true,
        "is_running": false,
        "series": [
          {
            "columns": [
              "time",
              "usage_idle"
            ],
            "values": [
              [
                1785427260000,
                91.5
              ]
            ]
          }
        ]
      }
    ],
    "declaration": null
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Responses

For authentication, rate limiting, and common request errors, see Common Error Definitions.

HTTP Status errorCode Trigger Condition Message or Response Description Handling
400 ft.JsonFormatError Legacy compatibility endpoint cannot parse parameters, or the JSON object lacks query content Some JSON file format error. For GET, pass body with URL encoding; for POST, pass a JSON object.
400 ft.TimeRangeUnitMismatch Start and end times of timeRange use different units Start and end time units are inconsistent. Use timestamps with the same precision.
403 ft.ForbiddenQuery API Key has no permission to query the target data, or the target site rejects the cross-site query with a permission error No DQL query permission. Verify the target Workspace authorization and target site.
406 ft.InvalidParameter interval or interval_unit does not meet the requirements Invalid parameter. Confirm the unit s/ms; it must be convertible to a positive integer number of milliseconds.
406 ft.DqlParseError DQL query statement cannot be parsed Query statement parsing failed; may contain detailed information. Validate the syntax in the query tool first.
406 ft.UnsupportMultiSiteQuery Batch query spans multiple sites Multi-site Workspace query is not supported. Submit a separate request for each site.
406 ft.workspaceUnauthorized An unauthorized Workspace was explicitly requested The message indicates the unauthorized Workspace. Obtain a valid identifier again from the authorized Workspace list.
406 ft.NotFoundWorkspaceAuthorizationCfg Cross-site query cannot find the corresponding authorization Workspace authorization information was not found. Verify the sharing configuration between the site and the Workspace.
406 ft.OpenapiDqlLoggingWildcardIndexForbidden Index settings restrict all-index queries Explicitly specify a Log Index. Get the index name from the Log Index list.
406 ft.OpenapiDqlLoggingIndexLimitExceeded Number of Log Indexes exceeds the configured limit The message contains the number of indexes that can be queried at a time. Narrow the index scope.
503 ft.QueryServiceUnavailable Query service is temporarily unavailable The query service is temporarily unavailable. Try again later. Retry with backoff according to content.retryable and the actual status.
406 ft.ParameterValidationFailed An undeclared Query parameter was passed Request field validation failed. Use only the query fields in the parameter table.

Feedback

Is this page helpful?