0.0.13 • Published 4 months ago

deepflow-sdk-js v0.0.13

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 months ago

deepflow-sdk-js

用于提供 deepflow querier 的 js sdk, 构造用于请求 querier 的 sql

API

由于向 querier 查询可用字段、待选项等会非常频繁,因此可能需要 API 支持 cancel 的能力。由于 querier.js 用于给不同项目使用,因此内置了一个 api 能力,但每个项目应根据自己情况,使用自己的 api 接口

使用外部 api:

import { setCreateReqFunc } from 'deepflow-sdk-js'
import dfApiCreator from 'my-api-creator'

setCreateReqFunc(dfApiCreator)

注意,setCreateReqFunc 接受的是一个函数,该函数的参数为:

  • method
  • url
  • params
  • headers 返回值为一个函数,执行该函数即发起查询。 返回的函数可以提供一个 cancel 方法,用于 cancel 该请求
let func = createCancelAbleFunc(url, method, params, headers)
func() //实际发起请求
func.cancel() //cancel该请求

绑定后端 querier 地址

import { setQuerierBaseUrl } from 'deepflow-sdk-js'
setQuerierBaseUrl('http://deepflow-querier:8080')

使用 dfQuery 来构造一个完整的搜索 sql

TODO

querier feature

  1. 查询到的 tag 结构,在 deepflow-sdk-js 内部会将resource类型的字段补上${resource}_id的字段,用于后续的转换
  2. 对 resource 类型的 select,自动添加对应的${resource}_id的 select,如 select vm 会变成 select vm, vm_id, groupBy 也同样会拼接
  3. 对于 resource 类型的 where 条件,当是 =, !=, IN, NOT IN 时,会自动转换为 resource_id
  4. 会将 groupBy 中第一个资源类型的分组条件,附加上 node_type(${resource})icon_id(${resource})的 select 内容,服务端和客户端会单独计算
  5. groupBy 的字段会自动加入到 select 中(groupBy 会自动检查字段是否在最终的 select 中)(group by enum 类型的会自动加上 enum(tag), bit_enum 除外)
  6. groupBy/orderBy 会自动查找 select 中是否有用过且有 as 的项,有的话直接复用 as 后的名称, 若存在多个匹配项, 使用第一个 有 as 的
  7. 有 groupBy 情况下,会检查 orderBy 中所有项,要求在 select 中出现。
  8. 没有 groupBy 情况下,having 条件应拼到 where 中。(6.3.5 后废弃)
  9. external 类型资源组,会额外增加:将其他所有资源组中资源类型的条件取反 not 资源组A中的资源查询条件 and not B and not C,...))
  10. metric function 使用 类 percentile 时, 参数 百分比 转为 小数
  11. 当参数里有any 时,资源类型 key 会转换为resource_id=0resource_id!=0,注意只有资源类型支持any,且需要是正向或者反向 op
  12. 当参数里有__disabled 时,会忽略该条件
  13. resource 类型的资源集会自动加上 is_internet=false,该条件在另一端为 internet 时失效。同时,资源外取反也不对该条件取反。
  14. 当 metric (如 byte > 100, sum(byte)> 100)在条件中出现时,如果是裸的 metric 条件,那么会拼接到 where 里。如果是聚合的 metric 条件,那么会拼接到 having 里
  15. 资源集在设置 uid 时,下发的 QUERY_ID 会按照 uid 进行下发
0.0.13

4 months ago

0.0.12

10 months ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.3

2 years ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago