Skip to content

Create Data Query Task



POST /api/v1/log_backup_cfg/query_task

Overview

Submit an asynchronous query task for data forwarding data.

Prerequisites and Usage Steps

You must pass a non-empty, exact name to select a rule that supports queries; an empty string may select the first available rule in the workspace, so never query with an empty string. Provide a millisecond time window and an optional regular expression object. The data read permission of the rule is validated first, and then the downstream asynchronous task is submitted; success only returns a task ID, which does not mean that any rows have been queried or that the task is complete. The client polls the result API with task_id; only task_status=completed indicates completion. At most 10 files are searched per request; if more files are needed, take the returned token and create another round of tasks with the same conditions.

Query targets support object storage/platform built-in objects, Doris, and LogBamboo with an independent searchToken; Kafka, Iceberg, and historical TiDB do not use this API. The request dataType does not change the rule category. A non-empty search must follow the conditions array structure; the task may already have been created before it fails due to context/cache or audit organization, so check task_id first after an error. A completed result requires the 12-hour query context cached by Studio to perform masking; if it has expired, recreate the task.

Request Headers

Parameter Name Type Required Description
DF-API-KEY string Y OpenAPI authentication credential for the workspace.
Example: <DF-API-KEY>
How to obtain or fill in: Obtain an OpenAPI Key with this operation permission from API Key Management in the target workspace.

Body Request Parameters

Parameter Name Type Required Description
search.conditions array Filter array; this is the query search structure, not extend.filters.
Example: [{"key": "message", "logic": "match", "value": "error.*"}]
How to obtain or fill in: Organize the regular expression conditions by key/value/logic for each item.
search.conditions[*] json A single query condition object.
Example: {"key": "message", "logic": "match", "value": "error.*"}
How to obtain or fill in: Construct it from actual data fields or full-text conditions.
search.conditions[*].key string Optional field key; do not treat arbitrary log display names as fields.
Example: message
How to obtain or fill in: Use the record field name; the key can be omitted for full-text search.
search.conditions[*].value string Regular expression search value, not a DQL statement.
Example: error.*
How to obtain or fill in: A valid regular expression, for example error.*.
search.conditions[*].logic string Use a case-accurate logic value.
Example: match
How to obtain or fill in: match to match, notMatch to exclude matches, according to the actual search protocol.
name string Y Declares a required string; the caller must submit a non-empty exact name. Currently an empty string adds no name filter, may take the first available rule in the workspace, and cannot be used to specify a target. Data reading is also controlled by rule permissions.
Null allowed: False
Example: production_archive
How to obtain or fill in: Take name rather than uuid from the data forwarding rule list.
search json Optional JSON object; you cannot use a JSON string from the Front end or a bare "error.*"; when non-empty, it should contain a conditions array to avoid audit text processing errors after the task is created.
Null allowed: False
Example: {"conditions": [{"key": "message", "logic": "match", "value": "error.*"}]}
How to obtain or fill in: Fill in according to the regular expression search object structure, or omit it/use {} for no filtering.
startTime string Y Required millisecond string, not seconds; the actual supported time window is constrained by the target query service, so query with a smaller window first.
Null allowed: False
Example: 1785427200000
How to obtain or fill in: Select the start of the query window with existing forwarded data in Unix milliseconds and convert it to a string.
endTime string Y Required; in Studio this route is not responsible for fully validating time order and available data range; errors are reported by the downstream.
Null allowed: False
Example: 1785430800000
How to obtain or fill in: The window end as a Unix millisecond string; the caller ensures it is later than the start.
token string The cursor is an opaque string; keep the same name, time, and search conditions, and do not construct it yourself or reuse it across rules.
Null allowed: False
Empty string allowed: True
Example:
How to obtain or fill in: Omit/leave empty in the first round; in subsequent rounds obtain it from content.token returned by get_result.
topN integer Optional, default 20; controls the number of rows and does not expand the protocol scope of searching at most 10 files per request.
Null allowed: False
$minValue: 1
$maxValue: 1000
Example: 20
How to obtain or fill in: Choose 1..1000 according to the expected number of rows returned per request.
dataType string Optional compatibility field; the controller always overrides it with the rule dataType and it does not switch the query category.
Null allowed: False
Empty string allowed: True
Valid values: ['lineage', 'metric', 'llm', 'logging', 'tracing', 'rum', 'keyevent', 'audit_event', 'am']
Example: logging
How to obtain or fill in: Use the current category of the rule; omitting it is recommended so that the rule takes precedence.

Additional Parameter Description

search Request Parameter Description

Parameter Name type Description
conditions array[json] Query conditions; each condition is a JSON object containing the fields: key, value, logic
operator string Logical operator; valid values: and, or

conditions Parameter Description

Parameter Name type Description
key string Field name
value string Field value
logic string Logical operator; valid values: match, notMatch

Request Example

curl --request POST 'https://openapi.guance.com/api/v1/log_backup_cfg/query_task' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  -H 'Content-Type: application/json' \
  --data-raw '{"name":"production_archive","startTime":"1785427200000","endTime":"1785430800000","search":{"conditions":[{"key":"message","logic":"match","value":"error.*"}]},"topN":20}'

Response

HTTP 200, application/json. The example below shows the main fields that can be read directly.

Field Type Description
content.task_id string Downstream asynchronous task ID; use this original string to call get_result; it is not cfg_uuid.
content.declaration object Common declaration for non-empty objects.
{
  "code": 200,
  "content": {
    "task_id": "task_example",
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

Error Response

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

For the following downstream query business errors, the SDK preserves the actual upstream 4xx status; do not judge only by the local default 406. An unrecognized downstream error_code is mapped to ft.BackuplogInternalServerError when the upstream returns 4xx while preserving the actual HTTP status; record the original error and traceId for troubleshooting. Ordinary upstream 5xx, timeouts, and similar failures are ultimately unified as 500 ft.InternalServerError.

errorCode Trigger and Handling
ft.BackuplogInvalidAPIArgs Downstream query time/filter/cursor and other parameters do not match; correct the parameters according to the downstream message and keep the same conditions for continued queries.
ft.BackuplogBucketNotFound The target object storage does not exist; verify the rule target and bucket lifecycle.
ft.BackuplogRuleNameInvalid The downstream rule name is invalid or the configuration is not synchronized; verify the current rule and backend status, then retry.
ft.BackuplogOSAccessDenied The downstream has no permission to read the target data; verify the target authorization, roles, and resource access policies.
HTTP Status errorCode Trigger Condition Message or Response Description Handling
406 ft.ParameterValidationFailed A request field is missing, or a field value violates the declared validation condition Parameter parsing failed Verify the parameter location, field name, type, and value.
400 ft.RequestJsonFormatError The request JSON syntax is invalid Request JSON format error Correct the JSON according to content.reason, line, and column.
400 ft.JsonFormatError The JSON top level is not an object Some json file format error Submit the JSON object in the parameter table.
404 ft.LogBackupCfgNoExists The non-empty rule name does not match a valid, non-deleted rule in the current workspace, or the rule is in deleting The specified data forwarding configuration does not exist Query by the current name in the list.
403 ft.NoLogBackupQueryPermission No data read permission for the rule You do not have permission to view data forwarding rule [{}] Query as the creator/owner or an identity allowed by readPermissionSet.
406 ft.ParameterValidationFailed The target is not queryable, such as Kafka/historical TiDB/Iceberg, or LogBamboo lacks an independent searchToken Parameter parsing failed Use a target that supports object queries, Doris, or a LogBamboo rule with a searchToken.
500 ft.InternalServerError Database, cache, field shape, or ordinary downstream 5xx/timeout handling failed Internal error After writing, first verify the current state of the rule; for query tasks, confirm task_id first; if the failure persists, provide the traceId.

Feedback

Is this page helpful?