4、azkaban-3.51.0 通过api进行操作azkaban界面功能
  nNPyvzOmRTFq 2023年11月02日 52 0

(文章目录)


本文主要介绍了azkaban通过api文档如何操作。

一、API Documentation

Often there’s a desire to interact with Azkaban without having to use the web UI. Azkaban has some exposed ajax calls accessible through curl or some other HTTP request clients. All API calls require a proper authentication first. Azkaban assumes the following request header in servlet’s isAjaxCall(HttpServletRequest request) method:

Content-Type:     application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest

However, currently for most of the APIs in this version, it is not checking the request header. Many APIs still treat a request as an ajax call if request simply contains the parameter ajax. Or even, several APIs are implicitly assuming it is an ajax call even without this keyword. For ease of use though, it is recommended to always keep the correct request header.

1、Authenticate

  • Method: POST
  • Request URL: /?action=login
  • Parameter Location: Request body This API helps authenticate a user and provides a session.id in response. Once a session.id has been returned, until the session expires, this id can be used to do any API requests with a proper permission granted. A session expires if you log out, change machines, browsers or locations, if Azkaban is restarted, or if the session expires. The default session timeout is 24 hours (one day). You can re-login whether the session has expired or not. For the same user, a new session will always override the old one. Importantly, session.id should be provided for almost all API calls (other than authentication). session.id can be simply appended as one of the request parameters, or set via the cookie: azkaban.browser.session.id. The two HTTP requests below are equivalent:
# a) Provide session.id parameter directly
curl -k --get --data "session.id=bca1d75d-6bae-4163-a5b0-378a7d7b5a91&ajax=fetchflowgraph&project=azkaban-test-project&flow=test" https://localhost:8443/manager

# b) Provide azkaban.browser.session.id cookie
curl -k --get -b "azkaban.browser.session.id=bca1d75d-6bae-4163-a5b0-378a7d7b5a91" --data "ajax=fetchflowgraph&project=azkaban-test-project&flow=test" https://localhost:8443/manager

2、Request Parameters

在这里插入图片描述

3、Response Object

在这里插入图片描述 A sample call via curl:

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

curl -k -X POST --data "action=login&username=azkaban&password=azkaban" http://192.168.10.41:8081

A sample response:

{
  "session.id" : "f6d9538d-6b2d-4f3a-acab-32d463691cca",
  "status" : "success"
}

二、Fetch user Projects

he ajax API for listing all existing projects for a user, which is the current user by default. Notice: If the user name supplied does not exist, the call will succeed and return a document where the projects value is an empty list.

  • Method: GET
  • Request URL: /index?ajax=fetchuserprojects
  • Parameter Location: Request Query

1、Request Parameters

在这里插入图片描述

2、Response Object 1. (if the request succeeds)

在这里插入图片描述

3、Response Object 2. (if the request fails)

在这里插入图片描述 Here’s a curl command sample:

curl -k -X GET https://localhost:8443/index?ajax=fetchuserprojects&user=alice&session.id=9089beb2-576d-47e3-b040-86dbdc7f523e
# 通过postman执行可以成功,通过命令执行提示session错误
curl -k -X GET http://192.168.10.41:8081/index?ajax=fetchuserprojects&user=azkaban&session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca

A sample response

{
    "projects": [
        {
            "projectId": 6,
            "projectName": "mutilexec",
            "createdBy": "azkaban",
            "createdTime": 1660786387756,
            "userPermissions": [
                {
                    "first": "azkaban",
                    "second": {
                        "types": [
                            "ADMIN"
                        ]
                    }
                }
            ],
            "groupPermissions": []
        }
    ]
}

三、Create a Project

The ajax API for creating a new project. Notice: before uploading any project zip files, the project should be created first via this API.

  • Method: POST
  • Request URL: /manager?action=create
  • Parameter Location: Request Query

1、Request Parameters

在这里插入图片描述

2、Response Object 1. (if the request succeeds)

在这里插入图片描述

3、Response Object 2. (if the request fails)

在这里插入图片描述 Here’s a curl command sample

curl -k -X POST --data "session.id=9089beb2-576d-47e3-b040-86dbdc7f523e&name=aaaa&description=11" https://localhost:8443/manager?action=create

curl -k -X POST --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&name=testapi_createproject&description=testapi" http://192.168.10.41:8081/manager?action=create

A sample response

{
    "path":"manager?project=testapi_createproject",
    "action":"redirect",
    "status":"success"
}

在这里插入图片描述

四、Delete a Project

The ajax API for deleting an existing project. Notice: Currently no response message will be returned after finishing the delete operation.

  • Method: GET
  • Request URL: /manager?delete=true
  • Parameter Location: Request Query

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample

curl -k --get --data "session.id=bca1d75d-6bae-4163-a5b0-378a7d7b5a91&delete=true&project=test-delete-project" https://localhost:8443/manager
#删除动作没有提示,直接删除掉了
curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&delete=true&project=testapi_createproject" http://192.168.10.41:8081/manager

五、Upload a Project Zip

The ajax call to upload a project zip file. The zip file structure should follow the requirements described in Upload Projects. Notice: This API should be called after a project is successfully created.

  • Method: POST
  • Content-Type: multipart/mixed
  • Request URL: /manager?ajax=upload
  • Parameter Location: Request Body

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample

curl -k -i -X POST --form 'session.id=e7a29776-5783-49d7-afa0-b0e688096b5e' --form 'ajax=upload' --form 'file=@myproject.zip;type=application/zip' --form 'project=MyProject' https://localhost:8443/manager

#先创建一个project,名称为testapi
curl -k -X POST --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&name=testapi&description=testapi" http://192.168.10.41:8081/manager?action=create
#上传zip文件,假设zip文件已经上传至执行目录
curl -k -i -X POST --form 'session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca' --form 'ajax=upload' --form 'file=@basicFlow20Project.zip;type=application/zip' --form 'project=testapi' http://192.168.10.41:8081/manager

A response sample

[root@server tools]# curl -k -i -X POST --form 'session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca' --form 'ajax=upload' --form 'file=@basicFlow20Project.zip;type=application/zip' --form 'project=testapi' http://192.168.10.41:8081/manager
HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 42
Server: Jetty(6.1.26)

{
  "projectId" : "8",
  "version" : "1"
}

在这里插入图片描述

六、Fetch Flows of a Project

Given a project name, this API call fetches all flow ids of that project.

  • Method: GET
  • Request URL: /manager?ajax=fetchprojectflows
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample

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

curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchprojectflows&project=testapi" http://192.168.10.41:8081/manager

A response sample

[root@server tools]# curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchprojectflows&project=testapi" http://192.168.10.41:8081/manager
{
  "flows" : [ {
    "flowId" : "basic"
  } ],
  "project" : "testapi",
  "projectId" : 8
}

七、Fetch Jobs of a Flow

For a given project and a flow id, this API call fetches all the jobs that belong to this flow. It also returns the corresponding graph structure of those jobs.

  • Method: GET
  • Request URL: /manager?ajax=fetchflowgraph
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample

curl -k --get --data "session.id=bca1d75d-6bae-4163-a5b0-378a7d7b5a91&ajax=fetchflowgraph&project=texter-1-1&flow=test" https://localhost:8445/manager
#该示例基于上传zip的那个示例,即上传的flow名称是basic
curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchflowgraph&project=testapi&flow=basic" http://192.168.10.41:8081/manager

A response sample

[root@server tools]# curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchflowgraph&project=testapi&flow=basic" http://192.168.10.41:8081/manager
{
  "nodes" : [ {
    "id" : "jobA",
    "type" : "command"
  }, {
    "id" : "jobB",
    "type" : "command"
  }, {
    "in" : [ "jobA", "jobB" ],
    "id" : "jobC",
    "type" : "noop"
  } ],
  "project" : "testapi",
  "projectId" : 8,
  "flow" : "basic"
}

八、Fetch Executions of a Flow(查询flow的执行记录)

Given a project name, and a certain flow, this API call provides a list of corresponding(相应) executions. Those executions are sorted in descendent submit time order. Also parameters are expected to specify the start index and the length of the list. This is originally used to handle pagination.

  • Method: GET
  • Request URL: /manager?ajax=fetchFlowExecutions
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

Here’s a curl command sample

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
#本示例是基于原azkaban用户下创建的mutilexec工程,flow名称为conditional_flow6的最近三次执行记录(倒序)
curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchFlowExecutions&project=mutilexec&flow=conditional_flow6&start=0&length=3" http://192.168.10.41:8081/manager

A response sample

[root@server tools]# curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchFlowExecutions&project=mutilexec&flow=conditional_flow6&start=0&length=3" http://192.168.10.41:8081/manager
{
  "total" : 6,
  "executions" : [ {
    "submitTime" : 1661153479886,
    "submitUser" : "azkaban",
    "startTime" : 1661153455580,
    "endTime" : 1661153455672,
    "flowId" : "conditional_flow6",
    "projectId" : 6,
    "execId" : 90,
    "status" : "SUCCEEDED"
  }, {
    "submitTime" : 1661153289558,
    "submitUser" : "azkaban",
    "startTime" : 1661153262061,
    "endTime" : 1661153262104,
    "flowId" : "conditional_flow6",
    "projectId" : 6,
    "execId" : 89,
    "status" : "FAILED"
  }, {
    "submitTime" : 1661153052912,
    "submitUser" : "azkaban",
    "startTime" : 1661153028603,
    "endTime" : 1661153028648,
    "flowId" : "conditional_flow6",
    "projectId" : 6,
    "execId" : 88,
    "status" : "KILLED"
  } ],
  "length" : 3,
  "project" : "mutilexec",
  "from" : 0,
  "projectId" : 6,
  "flow" : "conditional_flow6"
}

在这里插入图片描述

九、Fetch Running Executions of a Flow

Given a project name and a flow id, this API call fetches only executions that are currently running.

  • Method: GET
  • Request URL: /executor?ajax=getRunning
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample

curl -k --data "session.id=34ba08fd-5cfa-4b65-94c4-9117aee48dda&ajax=getRunning&project=azkaban-test-project&flow=test" https://localhost:8443/executor
#project=testapi&flow=basic,并且basic处于运行状态
curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=getRunning&project=testapi&flow=basic" http://192.168.10.41:8081/executor

在这里插入图片描述 A response sample

[root@server tools]# curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=getRunning&project=testapi&flow=basic" http://192.168.10.41:8081/executor
{
  "execIds" : [ 98 ]
}

十、Execute a Flow

This API executes a flow via an ajax call, supporting a rich selection of different options. Running an individual job can also be achieved via this API by disabling all other jobs in the same flow.

  • Method: POST
  • Request URL: /executor?ajax=executeFlow
  • Parameter Location: Request Query String

1、Request Parameters

2、Response Object

在这里插入图片描述

Here is a curl command example

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

curl -k -X POST --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=executeFlow&project=testapi&flow=basic" http://192.168.10.41:8081/executor

Sample response

[root@server tools]# curl -k -X POST --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=executeFlow&project=testapi&flow=basic" http://192.168.10.41:8081/executor
{
  "project" : "testapi",
  "message" : "Execution submitted successfully with exec id 99",
  "flow" : "basic",
  "execid" : 99
}

在这里插入图片描述

十一、Cancel a Flow Execution

Given an execution id, this API call cancels a running flow. If the flow is not running, it will return an error message.

  • Method: GET
  • Request URL: /executor?ajax=cancelFlow
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample

curl -k --data "session.id=34ba08fd-5cfa-4b65-94c4-9117aee48dda&ajax=cancelFlow&execid=302" https://localhost:8443/executor

curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=cancelFlow&execid=100" http://192.168.10.41:8081/executor

A response sample if succeeds

{ }

A response sample if fails

[root@server tools]# curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=cancelFlow&execid=100" http://192.168.10.41:8081/executor
{
  "error" : "java.io.IOException: Execution 100 is not running."
}

十二、Flexible(柔性) scheduling using Cron

This API call schedules a flow by a cron Expression. Cron is a UNIX tool that has been widely used for a long time, and we use Quartz library to parse cron Expression. All cron schedules follow the timezone defined in azkaban web server (the timezone ID is obtained by java.util.TimeZone.getDefault().getID()).

  • Method: POST
  • Request URL: /schedule?ajax=scheduleCronFlow
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample

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

curl -k -d ajax=scheduleCronFlow -d projectName=testapi -d flow=basic --data-urlencode cronExpression="0 * * ? * *  " -b "azkaban.browser.session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca" http://192.168.10.41:8081/schedule

An example success response

[root@server tools]# curl -k -d ajax=scheduleCronFlow -d projectName=testapi -d flow=basic --data-urlencode cronExpression="0 * * ? * *  " -b "azkaban.browser.session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca" http://192.168.10.41:8081/schedule
{
  "message" : "testapi.basic scheduled.",
  "scheduleId" : 2,
  "status" : "success"
}
An example failure response:
{
  "message" : "Cron expression must exist.",
  "status" : "error"
}
{
  "message" : "Permission denied. Cannot execute FLOW_NAME",
  "status" : "error"
}
An example failure response for invalid cron expression:
{
  "message" : "This expression <*****> can not be parsed to quartz cron.",
  "status" : "error"
}

在这里插入图片描述

十三、Fetch a Schedule

Given a project id and a flow id, this API call fetches the schedule.

  • Method: GET
  • Request URL: /schedule?ajax=fetchSchedule
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample:

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

curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchSchedule&projectId=8&flowId=basic" http://192.168.10.41:8081/schedule

An example success response:

[root@server tools]# curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchSchedule&projectId=8&flowId=basic" http://192.168.10.41:8081/schedule
{
  "schedule" : {
    "cronExpression" : "0 * * ? * *  ",
    "nextExecTime" : "2022-08-23 11:00:00",
    "period" : "null",
    "submitUser" : "azkaban",
    "executionOptions" : {
      "notifyOnFirstFailure" : true,
      "notifyOnLastFailure" : false,
      "failureEmails" : [ "noreply@foo.com" ],
      "successEmails" : [ ],
      "pipelineLevel" : null,
      "queueLevel" : 0,
      "concurrentOption" : "skip",
      "mailCreator" : "default",
      "memoryCheck" : true,
      "flowParameters" : {
      },
      "failureAction" : "FINISH_CURRENTLY_RUNNING",
      "disabledJobs" : [ ],
      "pipelineExecutionId" : null,
      "failureEmailsOverridden" : false,
      "successEmailsOverridden" : false
    },
    "scheduleId" : "2",
    "firstSchedTime" : "2022-08-23 10:53:05"
  }
}

If there is no schedule, empty response returns.

{}

在这里插入图片描述

十四、Unschedule a Flow

This API call unschedules a flow.

  • Method: POST
  • Request URL: /schedule?action=removeSched
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample:

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

curl -k http://192.168.10.41:8081/schedule -d "action=removeSched&scheduleId=2" -b azkaban.browser.session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca

An example success response:

[root@server tools]# curl -k http://192.168.10.41:8081/schedule -d "action=removeSched&scheduleId=2" -b azkaban.browser.session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca
{
  "message" : "flow basic removed from Schedules.",
  "status" : "success"
}
An example failure response:
{
  "message" : "Schedule with ID SCHEDULE_ID does not exist",
  "status" : "error"
}

在这里插入图片描述

十五、Set a SLA(Service-Level Agreement)

This API call sets a SLA.

  • Method: POST
  • Request URL: /schedule?ajax=setSla
  • Parameter Location: Request Query String azkaban上表示,在什么时候内满足什么条件.SLA的设置 不管是flow自带的邮件功能还是SLA,都是flow级别的预警,都不针对单个的job发邮件 在这里插入图片描述
  • FINISH 表示flow在要什么时间点之前完成,不管是success还是failure.
  • SUCCESS 表示flow要在什么时间点之前执行功能.

目前azkaban有两种action:

  • Emain Action 不满足SLA条件,则发送EAMIL
  • kill Actinon 不满足SLA条件,则kill flow

1、Request Parameters

Here’s a curl command sample:

curl -k -d "ajax=setSla&scheduleId=1&slaEmails=a@example.com;b@example.com&settings[0]=aaa,SUCCESS,5:00,true,false&settings[1]=bbb,SUCCESS,10:00,false,true" -b "azkaban.browser.session.id=XXXXXXXXXXXXXX" "http://localhost:8081/schedule"
#settings[0]=basic,SUCCESS,11:12,true,false&
#settings[1]=jobA,SUCCESS,11:12,false,true
#分别对应界面上的几个属性值,flow/job、SlaRule...

curl -k -d "ajax=setSla&scheduleId=3&slaEmails=alan.chan.chn@163.com;chenwei@blemall.com&settings[0]=basic,SUCCESS,11:12,true,false&settings[1]=jobA,SUCCESS,11:12,false,true" -b "azkaban.browser.session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca" "http://192.168.10.41:8081/schedule"

An example success response:

[root@server tools]# curl -k -d "ajax=setSla&scheduleId=3&slaEmails=alan.chan.chn@163.com;chenwei@blemall.com&settings[0]=basic,SUCCESS,11:12,true,false&settings[1]=jobA,SUCCESS,11:12,false,true" -b "azkaban.browser.session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca" "http://192.68.10.41:8081/schedule"
{
}
An example failure response:
{
  "error" : "azkaban.scheduler.ScheduleManagerException: Unable to parse duration for a SLA that needs to take actions!"
}

在这里插入图片描述

十六、Fetch a SLA

Given a schedule id, this API call fetches the SLA.

  • Method: GET
  • Request URL: /schedule?ajax=slaInfo
  • Parameter Location: Request Query String

1、Request Parameters

Here’s a curl command sample:

curl -k --get --data "session.id=XXXXXXXXXXXXXX&ajax=slaInfo&scheduleId=1" "http://localhost:8081/schedule"

curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=slaInfo&scheduleId=3" "http://192.168.10.41:8081/schedule"

An example success response:

[root@server tools]# curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=slaInfo&scheduleId=3" "http://192.168.10.41:8081/schedule"
{
  "settings" : [ {
    "duration" : "672m",
    "rule" : "SUCCESS",
    "id" : "basic",
    "actions" : [ "EMAIL" ]
  }, {
    "duration" : "672m",
    "rule" : "SUCCESS",
    "id" : "jobA",
    "actions" : [ "KILL" ]
  } ],
  "slaEmails" : [ "alan.chan.chn@163.com", "chenwei@blemall.com" ],
  "allJobNames" : [ "jobB", "jobA", "jobC" ]
}

十七、Pause a Flow Execution

Given an execution id, this API pauses a running flow. If an execution has already been paused, it will not return any error; if an execution is not running, it will return an error message.

  • Method: GET
  • Request URL: /executor?ajax=pauseFlow
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample:

curl -k --data "session.id=34ba08fd-5cfa-4b65-94c4-9117aee48dda&ajax=pauseFlow&execid=303" https://localhost:8443/executor

curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=pauseFlow&execid=109" http://192.168.10.41:8081/executor

A response sample (if succeeds, or pauseFlow is called multiple times):

{ }

A response sample (if fails, only when the flow is not actually running):

{
  "error" : "Execution 109 of flow test isn't running."
}

十八、Resume(恢复) a Flow Execution

Given an execution id, this API resumes a paused running flow. If an execution has already been resumed, it will not return any errors; if an execution is not running, it will return an error message.

  • Method: GET
  • Request URL: /executor?ajax=resumeFlow
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述 Here’s a curl command sample:

curl -k --data "session.id=34ba08fd-5cfa-4b65-94c4-9117aee48dda&ajax=resumeFlow&execid=303" https://localhost:8443/executor

curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=resumeFlow&execid=109" http://192.168.10.41:8081/executor

A response sample (if succeeds, or resumeFlow is called multiple times):

{ }

A response sample (if fails, only when the flow is not actually running):

{
  "error" : "Execution 109 of flow basic isn't running."
}

十九、Fetch a Flow Execution

Given an execution id, this API call fetches all the detailed information of that execution, including a list of all the job executions.

  • Method: GET
  • Request URL: /executor?ajax=fetchexecflow
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

It returns detailed information about the execution (check the example below). One thing to notice is that the field nodes[i].in actually indicates what are the dependencies of this node. Here’s a curl command sample:

curl -k --data "session.id=34ba08fd-5cfa-4b65-94c4-9117aee48dda&ajax=fetchexecflow&execid=304" https://localhost:8443/executor

curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchexecflow&execid=109" http://192.168.10.41:8081/executor

A response sample:

[root@server tools]# curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchexecflow&execid=109" http://192.168.10.41:8081/executor
{
  "project" : "testapi",
  "updateTime" : 1661224867922,
  "type" : null,
  "attempt" : 0,
  "execid" : 109,
  "submitTime" : 1661224892187,
  "nodes" : [ {
    "nestedId" : "jobB",
    "startTime" : 1661224867878,
    "updateTime" : 1661224867896,
    "id" : "jobB",
    "endTime" : 1661224867893,
    "type" : "command",
    "attempt" : 0,
    "status" : "SUCCEEDED"
  }, {
    "nestedId" : "jobA",
    "startTime" : 1661224867881,
    "updateTime" : 1661224867899,
    "id" : "jobA",
    "endTime" : 1661224867896,
    "type" : "command",
    "attempt" : 0,
    "status" : "SUCCEEDED"
  }, {
    "nestedId" : "jobC",
    "in" : [ "jobB", "jobA" ],
    "startTime" : 1661224867901,
    "updateTime" : 1661224867912,
    "id" : "jobC",
    "endTime" : 1661224867909,
    "type" : "noop",
    "attempt" : 0,
    "status" : "SUCCEEDED"
  } ],
  "nestedId" : "basic",
  "submitUser" : "azkaban",
  "startTime" : 1661224867875,
  "id" : "basic",
  "endTime" : 1661224867919,
  "projectId" : 8,
  "flowId" : "basic",
  "flow" : "basic",
  "status" : "SUCCEEDED"
}

二十、Fetch Execution Job Logs

Given an execution id and a job id, this API call fetches the corresponding job logs. The log text can be quite large sometimes, so this API call also expects the parameters offset and length to be specified.

  • Method: GET
  • Request URL: /executor?ajax=fetchExecJobLogs
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample:

curl -k --data "session.id=9089beb2-576d-47e3-b040-86dbdc7f523e&ajax=fetchExecJobLogs&execid=297&jobId=test-foobar&offset=0&length=100" https://localhost:8443/executor

curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchExecJobLogs&execid=110&jobId=jobA&offset=0&length=100" http://192.168.10.41:8081/executor

A response sample:

[root@server tools]# curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchExecJobLogs&execid=110&jobId=basic&offset=0&length=100" http://192.168.10.41:8081/executor
{
  "error" : "Job basic doesn't exist in 110"
}
[root@server tools]# curl -k --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchExecJobLogs&execid=110&jobId=jobA&offset=0&length=100" http://192.168.10.41:8081/executor
{
  "offset" : 0,
  "data" : "23-08-2022 11:24:07 CST jobA INFO - Starting job jobA at 1661225047892\n23-08-2022 11:24:07 CST jobA ",
  "length" : 100
}

二十一、Fetch Flow Execution Updates

This API call fetches the updated information for an execution. It filters by lastUpdateTime which only returns job information updated afterwards.

  • Method: GET
  • Request URL: /executor?ajax=fetchexecflowupdate
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample:

curl -k --data "execid=301&lastUpdateTime=-1&session.id=6668c180-efe7-46a-8dd2-e36508b440d8" https://localhost:8443/executor?ajax=fetchexecflowupdate

curl -k --data "execid=160&lastUpdateTime=-1&session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca" http://192.168.10.41:8081/executor?ajax=fetchexecflowupdate

A response sample:

[root@server tools]# curl -k --data "execid=160&lastUpdateTime=-1&session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca" http://192.168.10.41:8081/executor?ajax=fetchexecflowupdate
{
  "nodes" : [ {
    "startTime" : 1661233028638,
    "updateTime" : 1661233029139,
    "id" : "jobB",
    "endTime" : 1661233028935,
    "attempt" : 0,
    "status" : "SUCCEEDED"
  }, {
    "startTime" : 1661233028759,
    "updateTime" : 1661233029338,
    "id" : "jobA",
    "endTime" : 1661233029116,
    "attempt" : 0,
    "status" : "SUCCEEDED"
  }, {
    "startTime" : 1661233029377,
    "updateTime" : 1661233029908,
    "id" : "jobC",
    "endTime" : 1661233029676,
    "attempt" : 0,
    "status" : "SUCCEEDED"
  } ],
  "startTime" : 1661233028519,
  "updateTime" : 1661233030400,
  "id" : "basic",
  "endTime" : 1661233030235,
  "attempt" : 0,
  "flow" : "basic",
  "status" : "SUCCEEDED"
}

二十二、Fetch Logs of a Project

Given a project name, this API call fetches all logs of a project.

  • Method: GET
  • Request URL: /manager?ajax=fetchProjectLogs
  • Parameter Location: Request Query String

1、Request Parameters

在这里插入图片描述

2、Response Object

在这里插入图片描述 Here’s a curl command sample:

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

curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchProjectLogs&project=testapi" http://192.168.10.41:8081/manager

A response sample:

[root@server tools]# curl -k --get --data "session.id=f6d9538d-6b2d-4f3a-acab-32d463691cca&ajax=fetchProjectLogs&project=testapi" http://192.168.10.41:8081/manager
{
  "columns" : [ "user", "time", "type", "message" ],
  "logData" : [ 
      [ "azkaban", 1661224522540, "SLA", "SLA for flow basic has been added/changed." ], 
      [ "azkaban", 1661224154106, "SCHEDULE", "Schedule testapi.basic (8) to be run at (starting) 2022-08-23T11:09:14.099+08:00 with CronExpression {0 * * ? * * } has been added." ], 
      [ "azkaban", 1661223771205, "SCHEDULE", "Schedule testapi.basic (8) to be run at (starting) 2022-08-23T10:53:05.385+08:00 with CronExpression {0 * * ? * *  } has been removed." ], 
      [ "azkaban", 1661223185392, "SCHEDULE", "Schedule testapi.basic (8) to be run at (starting) 2022-08-23T10:53:05.385+08:00 with CronExpression {0 * * ? * *  } has been added." ], 
      [ "azkaban", 1661220409095, "UPLOADED", "Uploaded project files zip basicFlow20Project.zip" ], [ "azkaban", 1661220087533, "CREATED", null ] 
      ],
  "project" : "testapi",
  "projectId" : 8
}

以上,简单的介绍了azkaban的api文档操作及示例。

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  KRe60ogUm4le   2024年05月31日   101   0   0 flink大数据
  KRe60ogUm4le   2024年05月31日   34   0   0 flink大数据
nNPyvzOmRTFq
最新推荐 更多

2024-05-31