Azkaban WebApi 调用

目录

登录接口

获取projectid及flow列表

获取某个project下flow的schedule执行计划

修改执行时间

列表执行历史

执行flow

删除执行计划


 

官方文档:https://azkaban.readthedocs.io/en/latest/ajaxApi.html

 

登录接口

调用示例:

curl -k -X POST --data "action=login&username=azkaban&password=azkaban" https://localhost:8443

注意:文中请求均以curl命令形式展现,最后的url是请求的url,-X POST代表POST方式请求,--data或-d代表POST请求的BODY体

{
  "status" : "success",
  "session.id" : "c001aba5-a90f-4daf-8f11-62330d034c0a"
}

输出示例:

 

 

取到session.id后,后续请求需该参数保持登录状态。

 

获取projectid及flow列表

curl -k --get --data "session.id=6c96e7d8-4df5-470d-88fe-259392c09eea&ajax=fetchprojectflows&project=azkaban-test-project" https://localhost:8443/manager

 

输出示例:

{
  "project" : "test-azkaban",
  "projectId" : 192,
  "flows" : [ {
    "flowId" : "test"
  }, {
    "flowId" : "test2"
  } ]
}

 

 

获取某个project下flow的schedule执行计划

curl -k --get --data "session.id=XXXXXXXXXXXXXX&ajax=fetchSchedule&projectId=1&flowId=test" http://localhost:8081/schedule

 

输出示例:

{
  "schedule" : {
    "cronExpression" : "0 * 9 ? * *",
    "nextExecTime" : "2017-04-01 09:00:00",
    "period" : "null",
    "submitUser" : "azkaban",
    "executionOptions" : {
      "notifyOnFirstFailure" : false,
      "notifyOnLastFailure" : false,
      "failureEmails" : [ ],
      "successEmails" : [ ],
      "pipelineLevel" : null,
      "queueLevel" : 0,
      "concurrentOption" : "skip",
      "mailCreator" : "default",
      "memoryCheck" : true,
      "flowParameters" : {
      },
      "failureAction" : "FINISH_CURRENTLY_RUNNING",
      "failureEmailsOverridden" : false,
      "successEmailsOverridden" : false,
      "pipelineExecutionId" : null,
      "disabledJobs" : [ ]
    },
    "scheduleId" : "3",
    "firstSchedTime" : "2017-03-31 11:45:21"
  }
}

 

修改执行时间

curl -k -d ajax=scheduleCronFlow -d projectName=wtwt -d flow=azkaban-training --data-urlencode cronExpression="0 23/30 5,7-10 ? * 6#3" -b "azkaban.browser.session.id=XXXXXXXXXXXXXX" http://localhost:8081/schedule

输出示例:

{
  "message" : "PROJECT_NAME.FLOW_NAME scheduled.",
  "scheduleId" : SCHEDULE_ID,
  "status" : "success"
}

列表执行历史

curl -k --get --data "session.id=6c96e7d8-4df5-470d-88fe-259392c09eea&ajax=fetchFlowExecutions&project=azkaban-test-project&flow=test&start=0&length=3" https://localhost:8443/manager

start 开始位置

length 长度

 

输出示例:

{
  "total" : 2,
  "executions" : [ {
    "submitTime" : 1562914409512,
    "submitUser" : "azkaban",
    "startTime" : 1562914409540,
    "endTime" : 1562914409571,
    "flowId" : "command",
    "projectId" : 9,
    "execId" : 48,
    "status" : "SUCCEEDED"
  }, {
    "submitTime" : 1562913985555,
    "submitUser" : "azkaban",
    "startTime" : 1562913985583,
    "endTime" : 1562913985652,
    "flowId" : "command",
    "projectId" : 9,
    "execId" : 47,
    "status" : "SUCCEEDED"
  } ],
  "length" : 3,
  "project" : "whqtest",
  "from" : 0,
  "projectId" : 9,
  "flow" : "command"
}

 

执行flow

curl -k --get --data 'session.id=189b956b-f39f-421e-9a95-e3117e7543c9' --data 'ajax=executeFlow' --data 'project=azkaban-test-project' --data 'flow=test' https://localhost:8443/executor

返回值

{ message: "Execution submitted successfully with exec id 295", project: "foo-demo", flow: "test", execid: 295 }

 

删除执行计划

curl -k https://HOST:PORT/schedule -d "action=removeSched&scheduleId=SCHEDULE_ID" -b azkaban.browser.session.id=SESSION_ID

返回值

{ "message" : "PROJECT_NAME.FLOW_NAME scheduled.", "scheduleId" : SCHEDULE_ID, "status" : "success" }

 

你可能感兴趣的:(azkaban)