CreateServiceTask
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
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
cms:CreateServiceTask |
create |
*Service
|
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.