---
title: "query struct to promql"
method: POST
path: "/query/ts/struct_to_promql"
---

# query struct to promql

`POST /query/ts/struct_to_promql`

## Headers

- `traceparent` string
- `Bk-Query-Source` string
- `X-Bk-Scope-Space-Uid` string

## Request body

- StructuredQueryTs
  - `add_dimensions` string[] — AddDimensions 额外添加的聚合维度，会与每个 function.dimensions 合并
  - `clear_cache` boolean — ClearCache 是否强制清理已存在的缓存会话
  - `down_sample_range` string — DownSampleRange 降采样：大于Step才能生效，可以为空
  - `dry_run` boolean — DryRun 是否启用 DryRun
  - `end_time` string — End 结束时间：单位为任意长度的时间戳
  - `from` integer — From 翻页开启数字
  - `highlight` MetadataHighLight
    - `enable` boolean
    - `max_analyzed_offset` integer
  - `instant` boolean — Instant 瞬时数据
  - `is_es_batch` boolean — IsESBatch 是否启用 query_raw 的 ES 批量查询
  - `is_merge_db` boolean — IsMergeDB 是否启用合并 db 特性
  - `is_multi_from` boolean — IsMultiFrom 是否启用 MultiFrom 查询
  - `is_search_after` boolean — IsSearchAfter 是否启用 SearchAfter 查询
  - `limit` integer — 增加公共限制 Limit 点数限制数量
  - `look_back_delta` string — LookBackDelta 偏移量
  - `metric_merge` string — MetricMerge 表达式：支持所有PromQL语法
  - `not_time_align` boolean — NotTimeAlign 查询开始时间和聚合是否需要对齐 例如 true: range: 10:03 - 10:23 window: 10m -> 10:03 - 10:13, 10:13 - 10:23 false: range: 10:03 - 10:23 window: 10m -> 10:00 - 10:10, 10:10 - 10:20, 10:20 - 10:23
  - `order_by` string[] — OrderBy 排序字段列表，按顺序排序，负数代表倒序, ["_time", "-_time"]
  - `query_list` StructuredQuery[] — QueryList 查询实例
    - `collapse` MetadataCollapse
      - `field` string
    - `conditions` StructuredConditions
      - `condition_list` string[] — ConditionList 组合条件，长度 = len(FieldList) - 1的数组，支持 and,or
      - `field_list` StructuredConditionField[] — FieldList 查询条件
        - `field_name` string — DimensionName 过滤字段
        - `is_prefix` boolean — IsPrefix 是否是前缀
        - `is_suffix` boolean — IsSuffix 是否是后缀
        - `is_wildcard` boolean — IsWildcard 是否是通配符
        - `op` string — Operator 操作符，包含：eq,ne,erq,nreq,contains,ncontains
        - `value` string[] — Value 查询值
    - `dimensions` string[] — Dimensions promQL 使用维度
    - `field_name` string — FieldName 查询指标
    - `from` integer — From 翻页开启数字
    - `function` StructuredAggregateMethod[] — AggregateMethodList 维度聚合函数
      - `dimensions` string[] — Dimensions 聚合维度
      - `field` string — Field 聚合字段，默认为指标字段，指定则会进行覆盖
      - `is_sub_query` boolean — IsSubQuery 判断是否为子查询
      - `method` string — Method 聚合方法
      - `window` string — Window 聚合周期
      - `without` boolean — Without
    - `is_dom_sampled` boolean — IsDomSampled 是否命中降采样算法
    - `is_prefix` boolean — IsPrefix 是否启用前缀匹配
    - `is_regexp` boolean — IsRegexp 指标是否使用正则查询
    - `limit` integer — Limit 点数限制数量
    - `offset` string — Offset 偏移量
    - `offset_forward` boolean — OffsetForward 偏移方向，默认 false 为向前偏移
    - `query_string` string — QueryString 关键字查询
    - `reference_name` string — ReferenceName 别名，用于表达式计算
    - `slimit` integer — Slimit 维度限制数量
    - `sql` string — SQL doris sql 解析
    - `start_or_end` integer — StartOrEnd @-modifier 标记，start or end
    - `table_id` string — TableID 数据实体ID，容器指标可以为空
    - `table_id_conditions` array[] — TableIDConditions 表标签条件（Body table_id_conditions 与 PromQL __bk_query_label_selector_<维度> 写入此字段，用于路由选表）；AllConditions 形态，内层 AND、外层 OR。
      - StructuredConditionField[]
        - `field_name` string — DimensionName 过滤字段
        - `is_prefix` boolean — IsPrefix 是否是前缀
        - `is_suffix` boolean — IsSuffix 是否是后缀
        - `is_wildcard` boolean — IsWildcard 是否是通配符
        - `op` string — Operator 操作符，包含：eq,ne,erq,nreq,contains,ncontains
        - `value` string[] — Value 查询值
    - `time_aggregation` StructuredTimeAggregation
      - `function` string — Function 时间聚合方法
      - `is_sub_query` boolean — IsSubQuery 判断是否为子查询
      - `node_index` integer — NodeIndex 聚合函数的位置，用于还原 promql 的定位
      - `window` string — Window 聚合周期
    - `timestamp` integer — Timestamp @-modifier 标记
    - `vector_offset` -9223372036854776000 | 9223372036854776000 | 1 | 1000 | 1000000 | 1000000000 | 60000000000 | 3600000000000 | -9223372036854776000 | 9223372036854776000 | 1 | 1000 | 1000000 | 1000000000 | 60000000000 | 3600000000000
  - `reference` boolean — Reference 查询开始时间是否需要对齐， 例如： true: range: 10:03 - 10:23 window: 10m -> 10:03 - 10:10, 10:10 - 10:20, 10:20 - 10:23 false: range: 10:03 - 10:23 window: 10m -> 10:00 - 10:10, 10:10 - 10:20, 10:20 - 10:23
  - `result_table_options` MetadataResultTableOptions
  - `scroll` string — Scroll 是否启用 Scroll 查询
  - `slice_max` integer — SliceMax 最大切片数量
  - `space_uid` string — SpaceUid 空间ID
  - `start_time` string — Start 开始时间：单位为任意长度的时间戳
  - `step` string — Step 步长：最终返回的点数的时间间隔
  - `timezone` string — Timezone 时区
  - `tsdb_map` object — TsDBMap 查询路由匹配中的 tsDB 列表 key:reference_name

## Response `200`

OK

- StructuredQueryPromQL
  - `add_dimensions` string[] — AddDimensions 额外添加的聚合维度，会与每个 function.dimensions 合并
  - `bk_biz_ids` string[]
  - `down_sample_range` string — DownSampleRange 降采样：大于Step才能生效，可以为空
  - `end` string
  - `instant` boolean — 瞬时数据
  - `is_verify_dimensions` boolean
  - `limit` integer
  - `look_back_delta` string — LookBackDelta 偏移量
  - `match` string
  - `max_source_resolution` string
  - `not_align_influxdb` boolean — 不与influxdb对齐
  - `not_time_align` boolean
  - `promql` string
  - `reference` boolean
  - `slimit` integer
  - `start` string
  - `step` string
  - `timezone` string — Timezone 时区

## Other responses

- `400` — Bad Request

---

[API](https://skmtc.net/tencentblueking/apis/bk-unify-query.md) · [All operations](https://skmtc.net/tencentblueking/apis/bk-unify-query/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tencentblueking/bk-unify-query/versions/1c1ea4b46f93/schema)
