Creating a Flink Job
Function
This API is used to create and start a Flink job instance. This API is asynchronous. The response only indicates that the job creation request has been received. The actual running status can be queried by calling the Querying Flink Job Status API.
Supported job types:
Calling Method
For details, see Calling APIs.
URI
POST /v2/workspaces/{workspace_id}/flink-jobs
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| workspace_id | Yes | String | Definition: Workspace ID, used for resource isolation. For details about how to obtain the workspace ID, see Obtaining a Workspace ID. Constraints: N/A Range: 32 to 36 characters. Only letters, digits, and hyphens (-) are allowed. Default Value: N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition: User token, used for API authentication and authorization. It can be obtained by calling the Obtaining an IAM User Token API. Constraints: N/A Range: Up to 65,534 characters. Default Value: N/A |
| X-Client-Token | No | String | Definition: Client token, used for idempotency check of API calls. Constraints: N/A Range: 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Definition: Job name, used to identify the Flink job. Constraints: N/A Range: 1 to 128 characters. Must start and end with a letter or digit. Only letters, digits, underscores (_), and hyphens (-) are allowed. Default Value: N/A |
| endpoint_name | Yes | String | Definition: Endpoint name for job execution, used to specify the job execution environment. It can be obtained by calling the Listing Endpoints or Listing All Endpoints API. Constraints: N/A Range: 1 to 63 characters. Only lowercase letters, digits, and hyphens (-) are allowed. It must start with a lowercase letter and end with a lowercase letter or digit. Default Value: N/A |
| job_config | Yes | One of:
| Definition: Job configuration parameters, used to specify the Flink job type and execution parameters. The corresponding parameter structure is automatically selected based on the job type: FLINK_SQL_JOB corresponds to FlinkSqlParameter, FLINK_JAR_JOB corresponds to FlinkJarParameter. Constraints: N/A |
| deployment_id | No | String | Definition: ID of the deployed job, used to associate and aggregate Flink instances. Constraints: N/A Range: 1 to 64 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed. Default Value: N/A |
| job_agency | No | String | Definition: User-defined agency name, used to authorize the job to access OBS and other external resources. Constraints: The agency must already exist under the current account. System-managed agencies cannot be used to submit jobs. Range: 1 to 64 characters, with no character type restrictions. Default Value: If not specified, the endpoint job agency is used by default. |
| flink_config | No | Map<String,String> | Definition: User-defined Flink configuration parameters, in key-value pairs. Up to 100 parameters are supported, each value is 1 to 1,024 characters. System-reserved parameters such as execution.checkpointing.dir, execution.checkpointing.savepoint-dir, and high-availability.storageDir cannot be configured. These system-reserved parameters are automatically populated by the platform based on the endpoint configuration and returned in query responses, requiring no user configuration. Constraints: N/A |
| autoscaling_policy | No | AutoscalingPolicy object | Definition: Autoscaling configuration, used to automatically adjust the job parallelism. If not specified, autoscaling is disabled by default. Constraints: N/A |
| image_config | No | FlinkJobImageConfig object | Definition: Image configuration, used to specify the image information required for running the Flink job. If not specified, the system automatically selects the default image based on the endpoint configuration. Constraints: N/A |
| resource_config | No | FlinkResourceConfig object | Definition: Resource configuration, configuring the job parallelism and resource specifications of each component. Constraints: N/A |
| execution_mode | No | String | Definition: Execution mode, used to specify the Flink job execution mode. Constraints: N/A Range Default Value: STREAMING. |
| restore_strategy | No | RestoreStrategy object | Definition: Restoration policy configuration, used to specify the state restoration policy for the Flink job. Constraints: N/A |
| logging_config | No | FlinkLoggingConfig object | Definition: Log configuration. You can set the root log level and custom class log levels. Constraints: N/A |
| labels | No | Array of FlinkLabel objects | Definition: Tags, used for job classification and filtering. Constraints: The number of tags cannot exceed 16. |
| description | No | String | Definition: Description, used to describe the purpose of the job. Constraints: N/A Range: 1 to 512 characters. Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | No | String | Definition: Job type. Constraints: Fixed value: FLINK_SQL_JOB. Range: N/A Default Value: FLINK_SQL_JOB |
| sql_script_file | Yes | String | Definition: OBS file path of the SQL script, used to specify the script file for the SQL job. Constraints: N/A Range: OBS URL format, 1 to 512 characters, starting with obs://. Default Value: N/A |
| dependency_jars | No | Array of strings | Definition: OBS path list of JAR files that the SQL job depends on, used to specify the JAR files required for job execution. Each path is in OBS URL format, 1 to 512 characters, starting with obs://. Constraints: The number of dependent JAR files cannot exceed 100. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| type | No | String | Definition: Job type. Constraints: Fixed value: FLINK_JAR_JOB. Range: N/A Default Value: FLINK_JAR_JOB |
| main_jar | Yes | String | Definition: OBS path of the JAR file containing the main class, used to specify the entry JAR file. Constraints: N/A Range: 1 to 512 characters, starting with obs://. Default Value: N/A |
| main_class | No | String | Definition: Fully qualified name of the Jar job entry class, used to specify the entry class of the job. Can be omitted if the main class is already specified in the main program package manifest. Constraints: N/A Range: 1 to 512 characters, with no character type restrictions. Default Value: N/A |
| main_args | No | Array of strings | Definition: List of entry class parameters for the JAR job, passed in array order. Constraints: The number of parameters cannot exceed 100. |
| dependency_jars | No | Array of strings | Definition: OBS path list of the Jar job dependency JAR files, used to specify the JAR files required for job execution. Each path is in OBS URL format, 1 to 512 characters, starting with obs://. Constraints: The number of dependent JAR files cannot exceed 100. |
| dependency_files | No | Array of strings | Definition: OBS path list of the Jar job dependency files, used to specify the files required for job execution. Each path is in OBS URL format, 1 to 512 characters, starting with obs://. Constraints: The number of dependent files cannot exceed 100. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| enabled | No | Boolean | Definition: Whether to enable autoscaling. Constraints: N/A Range Default Value: false |
| vertex_max_parallelism | No | Integer | Definition: Maximum operator parallelism. Constraints: N/A Range: 1 to 1,000. Default Value: 1000 |
| quota_cpu | No | Integer | Definition: CPU quota (unit: millicores). Constraints: N/A Range: 500 to 40,000,000. Default Value: 16000 |
| quota_memory | No | Long | Definition: Memory quota (unit: MB). Constraints: N/A Range: 2,048 to 81,920,000. Default Value: 65536 |
| custom_config | No | Map<String,String> | Definition: User-defined autoscaling configuration parameters in key-value pairs, passed as job.autoscaler.* parameters supported by the Flink Kubernetes Operator. Up to 50 parameters are supported, each value is 1 to 1,024 characters. Constraints: Full replacement mode is used. When this field is specified, the current input takes effect. When this field is not specified, the custom autoscaling configuration remains unchanged. Parameter names must start with job.autoscaler.. Configuration for structured field keys with the same names (job.autoscaler.enabled, job.autoscaler.vertex.max-parallelism, job.autoscaler.quota.cpu, job.autoscaler.quota.memory) does not take effect. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| image_id | Yes | String | Definition: Image ID, used to specify the image required for running the Flink job. The image must already exist in the platform image management system. If a non-existent image is passed, the API returns an error. The image can be obtained through the platform image management feature. Constraints: This parameter must be used together with image_version_id, and both corresponding image versions must already exist. Range: 2 to 64 characters, with no character type restrictions. Default Value: N/A |
| image_version_id | Yes | String | Definition: Image version ID, used to specify the image version required for running the Flink job. The image version must already exist in the platform image management system. If a non-existent image version is passed, the API returns an error. The image version can be obtained through the platform image management feature. Constraints: This parameter must be used together with image_id, and both corresponding image versions must already exist. Range: 2 to 64 characters, with no character type restrictions. Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| parallelism | No | Integer | Definition: Job parallelism, determining the concurrent processing capability of the job. Constraints: N/A Range: 1 to 1,000. Default Value: 1 |
| jobmanager_resource_spec | No | FlinkResourceSpec object | Definition: JobManager resource specification, including CPU, memory, disk, etc. Constraints: N/A |
| taskmanager_resource_spec | No | FlinkResourceSpec object | Definition: TaskManager resource specification, including CPU, memory, disk, etc. Constraints: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| cpu | No | Integer | Definition: Number of CPU millicores, in millicores, used to specify the CPU resources of the JobManager or TaskManager. Constraints: N/A Range: 500 to 48,000. Default Value: 1000. |
| memory | No | Integer | Definition: Memory size, in MB, used to specify the memory resources of the JobManager or TaskManager. Constraints: N/A Range: 2,048 to 393,216. Default Value: 4096. |
| disk | No | Integer | Definition: Pod ephemeral storage capacity, in GB, used to store temporary files during job execution. Ephemeral storage is not persistent. Constraints: N/A Range: 30 to 1,024. Default Value: 30. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| restore_type | Yes | String | Definition: Restoration type, used to specify the job restoration policy. Constraints: N/A Range
Default Value: N/A |
| savepoint_id | No | String | Definition: Savepoint ID, used to uniquely identify a snapshot. Mandatory only when restore_type is FROM_SAVEPOINT_ID. You can obtain it by calling the Listing Flink Job Savepoints or Creating a Flink Job Savepoint API. Constraints: The savepoint ID must already exist. If a non-existent savepoint ID is passed, the API returns a 404 error. Range: UUIDv7 format, fixed at 36 characters. Only lowercase letters, digits, and hyphens (-) are allowed. Default Value: N/A |
| checkpoint_path | No | String | Definition: Checkpoint storage path, pointing to the parent directory of the _metadata file. Mandatory only when restore_type is FROM_CHECKPOINT_PATH. Constraints: N/A Range: 1 to 512 characters, must start with obs://. Default Value: N/A |
| allow_non_restored_state | No | Boolean | Definition: Whether to allow ignoring partial operator state. Mandatory only for JAR jobs with restore_type of FROM_SAVEPOINT_ID or FROM_CHECKPOINT_PATH. Constraints: N/A Range
Default Value: N/A |
| job_start_time_in_ms | No | Long | Definition: Timestamp for the data consumption start point of the source table, used to specify when the job starts consuming data from the source table. This parameter is mandatory only when restore_type is set to FROM_SPECIFIED_TIMESTAMP, and it is supported only for Kafka source tables. Constraints: N/A Range: 0 to 4,102,416,000,000, 13-digit millisecond timestamp. Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| root_logger_level | No | String | Definition: Root log level configuration, used to control the overall log output level of the job. Constraints: N/A Range Default Value: N/A |
| log4j_loggers | No | Array of FlinkLog4jLoggers objects | Definition: Name of the output log class and the corresponding log level configuration, used to set a specific log level for a specified class. Constraints: The number of configuration items cannot exceed 20. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| logger_name | Yes | String | Definition: Name of the class for which logs are output, used to specify the class that requires log level configuration. Constraints: N/A Range: 1 to 256 characters, with no character type restrictions. Default Value: N/A |
| logger_level | Yes | String | Definition: Output log level, used to control the log output level for the class. Constraints: N/A Range Default Value: N/A |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| key | Yes | String | Definition: Tag key. Constraints: N/A Range: 1 to 128 characters. The equal sign (=) is not allowed. Default Value: N/A |
| value | Yes | String | Definition: Tag value. Constraints: N/A Range: 1 to 512 characters, with no character type restrictions. Default Value: N/A |
Response Parameters
Status code: 201
| Parameter | Type | Description |
|---|---|---|
| job_id | String | Definition: Flink job ID. Range: UUIDv7 format, fixed at 36 characters. Only lowercase letters, digits, and hyphens (-) are allowed. |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition: Error code, used to identify a specific error type. Range: 1 to 256 characters. |
| error_msg | String | Definition: Error message, used to explain the cause of an error. Range: 1 to 1,024 characters. |
| solution_msg | String | Definition: Resolution suggestion, used to provide a solution for the error. Range: 0 to 1,024 characters. |
Status code: 401
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition: Error code, used to identify a specific error type. Range: 1 to 256 characters. |
| error_msg | String | Definition: Error message, used to explain the cause of an error. Range: 1 to 1,024 characters. |
| solution_msg | String | Definition: Resolution suggestion, used to provide a solution for the error. Range: 0 to 1,024 characters. |
Status code: 403
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition: Error code, used to identify a specific error type. Range: 1 to 256 characters. |
| error_msg | String | Definition: Error message, used to explain the cause of an error. Range: 1 to 1,024 characters. |
| solution_msg | String | Definition: Resolution suggestion, used to provide a solution for the error. Range: 0 to 1,024 characters. |
Status code: 404
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition: Error code, used to identify a specific error type. Range: 1 to 256 characters. |
| error_msg | String | Definition: Error message, used to explain the cause of an error. Range: 1 to 1,024 characters. |
| solution_msg | String | Definition: Resolution suggestion, used to provide a solution for the error. Range: 0 to 1,024 characters. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Definition: Error code, used to identify a specific error type. Range: 1 to 256 characters. |
| error_msg | String | Definition: Error message, used to explain the cause of an error. Range: 1 to 1,024 characters. |
| solution_msg | String | Definition: Resolution suggestion, used to provide a solution for the error. Range: 0 to 1,024 characters. |
Example Requests
-
Create and start a Flink SQL job, specifying the job name, endpoint, SQL script path, resource configuration, etc.
POST /v2/workspaces/{workspace_id}/flink-jobs { "name" : "test-flink-job", "description" : "Test Flink SQL job.", "endpoint_name" : "test-endpoint", "job_agency" : "test-agency", "execution_mode" : "STREAMING", "job_config" : { "type" : "FLINK_SQL_JOB", "sql_script_file" : "obs://my-flink-bucket/path/to/script.sql", "dependency_jars" : [ "obs://my-flink-bucket/path/to/dep1.jar" ] }, "flink_config" : { "taskmanager.numberOfTaskSlots" : "1" }, "autoscaling_policy" : { "enabled" : true, "vertex_max_parallelism" : 1000, "quota_cpu" : 4000, "quota_memory" : 8192, "custom_config" : { "job.autoscaler.target.utilization" : "0.6", "job.autoscaler.target.catch-up.duration" : "10 min" } }, "resource_config" : { "parallelism" : 1, "jobmanager_resource_spec" : { "cpu" : 1000, "memory" : 4096 }, "taskmanager_resource_spec" : { "cpu" : 1000, "memory" : 4096 } } } -
Create and start a Flink Jar job, specifying the main JAR file, main class, entry parameters, etc.
POST /v2/workspaces/{workspace_id}/flink-jobs { "name" : "test-flink-jar-job", "description" : "Test Flink Jar job.", "endpoint_name" : "test-endpoint", "job_agency" : "test-agency", "execution_mode" : "STREAMING", "job_config" : { "type" : "FLINK_JAR_JOB", "main_jar" : "obs://my-flink-bucket/path/jars/WindowJoin.jar", "main_class" : "org.apache.flink.streaming.examples.join.WindowJoin", "main_args" : [ "--input", "obs://bucket/input/", "--output", "obs://bucket/output/" ], "dependency_jars" : [ "obs://my-flink-bucket/path/to/dep1.jar" ], "dependency_files" : [ "obs://my-flink-bucket/path/to/config.csv" ] }, "resource_config" : { "parallelism" : 1, "jobmanager_resource_spec" : { "cpu" : 1000, "memory" : 4096 }, "taskmanager_resource_spec" : { "cpu" : 1000, "memory" : 4096 } } }
Example Responses
Status code: 201
-
Create and start a Flink SQL job, specifying the job name, endpoint, SQL script path, resource configuration, etc.
{ "job_id" : "019f609a-e90c-xxxx-xxxx-a4ec9018e7f2" } -
Create and start a Flink Jar job, specifying the main JAR file, main class, entry parameters, etc.
{ "job_id" : "019f609a-e90c-xxxx-xxxx-b4ec9018e7f3" }
Status code: 400
{
"error_code" : "AIDataLake.01011001",
"error_msg" : "Invalid parameter",
"solution_msg" : "Please check the input parameters according to the documentation."
} Status code: 401
{
"error_code" : "AIDataLake.01011003",
"error_msg" : "Auth Token not exists in header",
"solution_msg" : "Please check if auth Token is included in the request header."
} Status code: 403
{
"error_code" : "AIDataLake.01011005",
"error_msg" : "Current account has no permission",
"solution_msg" : "Please connect administrators to add permission."
} Status code: 404
{
"error_code" : "AIDataLake.01051101",
"error_msg" : "Flink savepoint 019f68a2-5e11-xxxx-xxxx-6e670d65ab03 does not exist",
"solution_msg" : "Please check if Flink savepoint 019f68a2-5e11-xxxx-xxxx-6e670d65ab03 is entered correctly or has been deleted"
} Status code: 500
{
"error_code" : "AIDataLake.01010001",
"error_msg" : "Internal system error",
"solution_msg" : "Contact operations for analysis."
} Status Codes
| Status Code | Description |
|---|---|
| 201 | Request submitted. |
| 400 | Invalid request parameters. |
| 401 | Authentication failed. |
| 403 | Insufficient permissions. |
| 404 | The Flink savepoint does not exist. |
| 500 | Internal system error. |
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot