智能日志管理平台

  • 智能日志管理平台 > API 文档 > 工作流 API > 创建流式计算任务

    创建流式计算任务

    最近更新时间: 2018-09-25 18:32:53

    请求语法

    POST /v2/repos/<RepoName>/transforms/<TransformName>/to/<DestinationRepoName>
    Content-Type: application/json
    Authorization: Pandora <auth>
    {
      "plugin": {
        "name": <PluginName>,
        "output": [
          {
            "name": <FieldName1>,
            "type": <FieldType>
          },
          {
            "name": <FieldName2>
          },
          ......
        ],
      },
      "mode": <Mode>,
      "code": <Code>,
      "interval": <Interval>,
      "container": {
           "type": <ContainerType>,
           "count": <ContainerCount>
      },
      "whence": <TransformWhence>,
      "destrepo": [
          {
            "key": <Key>,
            "valtype": <ValueType>,
            "elemtype": <ElemType>,
            "required": <Required>,
            "schema": [
                ...
            ]
          },
          ...
      ]
    
    }
    

    请求内容

    参数 类型 必填 说明
    RepoName string 指定一个消息队列的名称
    TransformName string 计算任务名称
    用来标识该消息队列的唯一性
    命名规则: ^[a-zA-Z_][a-zA-Z0-9_]{0,127}$
    DestinationRepoName string 计算结果输出消息队列
    如果该消息队列不存在
    将自动创建一个
    plugin json 自定义计算
    name string 自定义计算名称
    output json 输出数组
    即这个plugin计算完成后,输出的数据结果的结构和类型
    也可以理解为一张表,包含字段名称和字段类型
    output.name string 输出字段名称
    命名规则: ^[a-zA-Z_][a-zA-Z0-9_]{0,127}$
    output.type string 输出字段类型
    支持stringlongfloat三种
    时间类型使用long类型
    默认为string类型
    mode string 该计算任务使用的语言类型
    目前仅支持sql
    code string sql语句代码
    interval string 计算任务的运行时间间隔
    目前支持5s10s20s30s
    1m5m10m的粒度
    如果不指定,系统默认使用1m
    container map 计算资源的数量及类型
    type string 目前支持1U2G1U4G2U4G4U8G4U16G8U16G
    分别代表
    1核(CPU)2G(内存)1核(CPU)4G(内存)2核(CPU)4G(内存)4核(CPU)8G(内存)4核(CPU)16G(内存)8核(CPU)16G(内存)
    count int 指资源type的数量,最小为1,没有上限
    whence string 计算数据的起始位置, 目前支持oldest、newest, 分别表示从指定仓库的最早、最新数据开始计算, 默认值为newest

    !> 注意:modecode是基础的数据计算方式,自定义计算(plugin)是更为高级的数据计算方式,要注意mode/code和自定义计算两种计算方式可以共存,但不可以一种都不指定。当自定义计算和mode/code共存时,系统优先执行自定义计算,后执行mode/code。

    示例

    curl -X POST https://nb-pipeline.qiniuapi.com/v2/repos/test_repo/transforms/transform_job/to/compute_repo \
         -H 'Content-Type: application/json' \
         -H 'Authorization: Pandora 2J1e7iG13J66GA8vWBzZdF-UR_d1MF-kacOdUUS4:NTi3wH_WlGxYOnXsvgUrO4XMD6Y=' \
         -d {
              "mode": "sql",
              "code": "select count(*) from test_repo",
              "interval": "1m",
              "container": {
                   "type": "M16C4",
                   "count": 5
                  }
            }
    
    以上内容是否对您有帮助?
  • Qvm free helper
    Close