Skip to content

SLS to DQL



POST /api/v1/sls/convert

Overview

Converts Alibaba Cloud SLS query statements to log DQL. This endpoint only performs syntax conversion and does not query or modify workspace data.

Header Request Parameters

Parameter Name Type Required Description
DF-API-KEY string Yes API Key identifier.

Body Request Parameters

Parameter Name Type Required Description
query string Yes The Alibaba Cloud SLS query statement to convert. Must not be empty.
indexes array No Log index name list. If omitted or an empty array is passed, the generated DQL will not have index restrictions.

Response Description

The conversion result is in the content of the response:

Field Type Description
status string Conversion status, can be exact, approximate, or unsupported.
dql string The converted log DQL; may be empty if the current syntax is not supported.
diagnostics array Conversion diagnostic information, used to explain approximate conversions or unsupported syntax. Returns an empty array for exact with no diagnostics.

Status meanings:

  • exact: The generated DQL is equivalent to the original SLS query.
  • approximate: An approximate DQL has been generated. Before execution, check the semantic differences using diagnostics.
  • unsupported: The current SLS syntax is not supported; dql may be empty.

The conversion result always uses the log namespace L. indexes is only used to generate the DQL text; the endpoint does not verify whether the indexes exist. When executing the conversion result later, the corresponding data query endpoint will still perform permission and data access rule verification.

Example Request

curl 'https://openapi.guance.com/api/v1/sls/convert' \
  -H 'Content-Type: application/json' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  --data-raw '{"query":"status:200","indexes":["default"]}'

Example Response

{
  "code": 200,
  "content": {
    "status": "exact",
    "dql": "L::re(`.*`):(*)",
    "diagnostics": []
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-XXXX"
}

Feedback

Is this page helpful?