Updated on 2024-11-06 GMT+08:00

Querying Instances of a Specified Job

Function

This API is used to query the instances of a job based on the job name.

URI

  • URI format

    GET /v2/{project_id}/factory/jobs/{job_name}/instances/detail

    ?min_plan_time={min_plan_time}&max_plan_time={max_plan_time}&limit={limit}&offset={offset}&status={status}&instance_type={instance_type}&force_success={force_success}&ignore_success={ignore_success}

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Project ID. For details about how to obtain a project ID, see Project ID and Account ID.

    job_name

    Yes

    String

    Job name

    • If you want to query the instance list of a specific batch job, job_name is the batch job name.
    • If you want to query sub-jobs associated with a node in a real-time job, the job_name format is Real-time job name_Node name.

    min_plan_time

    No

    Long

    Minimum planned job execution time in milliseconds. Job instances whose start time is later than this time are returned. The default value is 00:00:00 of the current day. Instances of up to one month can be queried.

    max_plan_time

    No

    Long

    Minimum planned job execution time in milliseconds. Job instances whose start time is earlier than this time are returned. The default value is the current time.

    limit

    No

    int

    Maximum number of records on each page

    The parameter value ranges from 1 to 1000.

    Default value: 10

    offset

    No

    int

    Start page of the paging list. The default value is 0. The value must be greater than or equal to 0.

    status

    No

    String

    Job instance status

    • waiting
    • running
    • success
    • fail
    • running-exception
    • skip-by-depend
    • freeze
    • pause
    • manual-stop

    By default, all instances will be queried.

    instance_type

    No

    int

    Job scheduling mode

    • 0: general scheduling
    • 2: manual scheduling
    • 5: PatchData
    • 6: subjob scheduling
    • 7: one-off scheduling

    By default, all instances will be queried.

    force_success

    No

    boolean

    This parameter is available when status is success. If this parameter is set to true, job instances that were forced to be successful will be queried.

    Default value: false

    ignore_success

    No

    boolean

    This parameter is available when status is success. If this parameter is set to true, job instances whose failures were ignored will be queried.

    Default value: false

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

workspace

No

String

Workspace ID

  • If this parameter is not set, data in the default workspace is queried by default.
  • To query data in other workspaces, this header must be carried.

Response Parameters

Table 3 Parameter description

Parameter

Mandatory

Type

Description

total

Yes

Long

Total number of records

instances

Yes

List<Instance>

Job instance status. For details, see Table 4.

Table 4 instances parameters

Parameter

Mandatory

Type

Description

job_name

Yes

String

Job name. When you view the instance list of a specified batch job, job_name is the name of the batch job. When you view the subjobs associated with a node in a real-time job, job_name is in format of real-time job name_node name.

job_id

No

Long

Job ID

job_instance_name

Yes

String

Name of a job instance recorded by the log, rather than the name defined during job creation

status

Yes

String

Job instance status

  • waiting
  • running
  • success
  • fail
  • running-exception
  • skip-by-depend
  • freeze
  • pause
  • manual-stop

plan_time

Yes

Long

Planned execution time of the job instance

start_time

Yes

Long

Actual execution start time of the job instance

end_time

No

Long

Actual execution end time of the job instance

execute_time

No

Long

Execution duration in milliseconds

instance_id

Yes

Long

Job instance ID, which is used to query job instance details

submit_time

Yes

Long

Time when a job is submitted

instance_type

Yes

int

Job scheduling mode

  • 0: general scheduling
  • 2: manual scheduling
  • 5: PatchData
  • 6: subjob scheduling
  • 7: one-off scheduling

force_success

No

boolean

Whether the job instance status is forcibly successful

Default value: false

ignore_success

No

boolean

Whether the job instance status is failure ignored

Default value: false

version

No

int

Job instance version

Example Request

View the instance list of batch job job_batch.
GET /v2/b384b9e9ab9b4ee8994c8633aabc9505/factory/jobs/job_batch/instances/detail

Example Response

  • Success response
    HTTP status code 200
    {
    	"total": 2,
    	"instances": [{
    		"end_time": 1551671598000,
    		"execute_time": 0.3,
    		"force_success": false,
    		"ignore_success": false,
    		"instance_id": 34765,
    		"instance_type": 2,
    		"job_id": 608627,
    		"job_name": "job_batch",
    		"job_instance_name": "job_batch",
    		"plan_time": 1551671580000,
    		"start_time": 1551671580000,
    		"status": "success",
    		"submit_time": 1550910278706,
    		"version": 1
    	},
    	{
    		"end_time": 1551671538000,
    		"execute_time": 0.3,
    		"force_success": false,
    		"ignore_success": false,
    		"instance_id": 34764,
    		"instance_type": 5,
    		"job_id": 608627,
    		"job_name": "job_batch",
    		"job_instance_name": "job_batch",
    		"plan_time": 1551671520000,
    		"start_time": 1551671521000,
    		"status": "success",
    		"submit_time": 1550910278706,
    		"version": 1
    	}]
    }
  • Failure response

    HTTP status code 400

    {
        "error_code": "DLF.0100",
        "error_msg": "The job does not exists."
    }