CreateServiceTask

Updated at:

Creates a ServiceTask (heap dump or LiveDebug diagnostic task) for a specified application.

Operation description

Creates a service task for an application in a specified workspace.

Common use cases:

  • heapdump: Triggers a JVM heap dump.

  • LiveDebug Probe: Dynamically instruments target methods (logs, snapshots, metrics, spans, etc.).

  • LiveDebug Command: Performs one-time proactive inspections (OGNL, decompilation, thread/memory information, etc.).

  • LiveDebug Code Replace: Hot-swaps code.

After the task is created, a taskId is returned. You can use GetServiceTask, ListServiceTask, or DeleteServiceTask to manage the task. After a LiveDebug task is created, the configuration is synchronized to ConfigServer.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

cms:CreateServiceTask

create

*Service

acs:cms:{#regionId}:{#accountId}:serviceTask/{#Workspace}/{#serviceId}/task

None None

Request syntax

POST /serviceTask/{workspace}/{serviceId}/task HTTP/1.1

Path Parameters

Parameter

Type

Required

Description

Example

workspace

string

Yes

The workspace name. Example: default-cms--.

default-cms-1672753017899339-cn-hangzhou

serviceId

string

Yes

The application or service ID (pid).

ggxw4lnjuz@f2fd3a6265a254a052afb

Request parameters

Parameter

Type

Required

Description

Example

body

object

No

The request body for creating a task.

ip

string

Yes

The IP address of the target instance. This parameter is optional. If not specified, some tasks can be matched by instance scope (such as instanceIds). This parameter is usually required for heap dump scenarios.

10.0.0.1

type

string

No

The task type. This parameter is required. Valid values: heapdump (heap dump); LiveDebug Probe: live_debug_log_probe, live_debug_snapshot_probe, live_debug_metric_probe, live_debug_span_probe, and live_debug_span_tag_probe; LiveDebug Command: live_debug_inspect_object, live_debug_search_type, live_debug_search_method, live_debug_decompile, live_debug_get_thread_info, live_debug_get_runtime_info, live_debug_get_memory_info, live_debug_evaluate_expression, and live_debug_modify_logger_level; LiveDebug Code Replace: live_debug_code_replace.

live_debug_log_probe

taskConfig

string

No

The task configuration. The value is a JSON string with a maximum length of 65,536 characters. This parameter is required for LiveDebug tasks. Use a flat JSON structure and pass a single command or probe object directly. Do not wrap it in a commands or probes array. Probe example (dynamic log): {"probeType":"LOG","language":"java","target":{"typeName":"com.example.UserService","methodName":"getUser","location":"exit","instanceIds":[""]},"action":{"type":"LOG","template":"userId=${args[0]}","templateSegments":[{"type":"TEXT","value":"userId="},{"type":"EXPRESSION","value":"args[0]"}]},"ttl":"1h","captureCount":100}. Command example (OGNL): {"commandType":"EVALUATE_EXPRESSION","language":"java","params":{"expression":"@java.lang.System@getProperty("java.home")"},"instanceIds":[""]}. Note: The top level of a Command type must contain instanceIds. For a Probe, place instanceIds inside target. For a METRIC probe, the valid values for action.metricType are COUNTER, GAUGE, HISTOGRAM, and SUMMARY. The Java agent supports only COUNTER and GAUGE.

{"probeType":"LOG","language":"java","target":{"typeName":"com.example.service.UserServiceImpl","methodName":"findById","location":"exit","instanceIds":["*"]},"action":{"type":"LOG","template":"userId=${args[0]} cost=${durationMs}ms","templateSegments":[{"type":"TEXT","value":"userId="},{"type":"EXPRESSION","value":"args[0]"},{"type":"TEXT","value":" cost="},{"type":"EXPRESSION","value":"durationMs"},{"type":"TEXT","value":"ms"}]},"ttl":"1h","captureCount":100}

The request includes the path parameters workspace and serviceId, and the body parameters type, ip, and taskConfig.

Response elements

Element

Type

Description

Example

object

The response for a successful creation.

requestId

string

The request ID.

A1B2C3D4-E5F6-7890-ABCD-EF1234567890

taskId

string

The ID of the created task. You can use this ID for subsequent queries or deletions.

a1b2c3d4-e5f6-7890-abcd-ef1234567890

The response returns the request ID and the ID of the created task.

Examples

Success response

JSON format

{
  "requestId": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890",
  "taskId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.