通过curl请求来调用Azkaban WebApi


azkaban api 官方文档

1.登录接口

调用示例:

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后,后续请求需该参数保持登录状态。

2.获取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"
  } ]
}

3.获取某个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"
  }
}

4.修改执行时间

调用示例:

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"
}

5.列表执行历史

调用示例:

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"
}

6.执行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 
}

7.删除执行计划

调用示例:

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"
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

明月清风,良宵美酒

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值