You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Log management API
CreateDownloadTask
Copy page
Download PDF
CreateDownloadTask
Call the CreateDownloadTask API to create a log download task.​
Instructions​
This API creates a log download task, supporting downloads of raw logs within a specified time period or downloads of query and analysis results. After the download task is successfully created, you can view the task status via DescribeDownloadTasks and obtain the download link using the DescribeDownloadUrl API.​
The call frequency limit for this API is 20 times per second. Exceeding the limit will result in an ExceedQPSLimit error.​
When downloading logs, the data volume for download tasks is subject to the following restrictions:​
tip​
For large data volumes, it is recommended to reduce the time range and download in multiple sessions.​
​
Actions​
Description​
Only query or preview logs​
  • You can download up to 20 million rows of log data that meet the query criteria in a single batch, with a data limit of 20 GiB. If the limit is exceeded, only the earliest 20 million lines or the first 20 GiB of log data will be downloaded​
  • If more than 20 GiB, the Export History page displays File Generation Interrupted​
Query and analyze logs​
You can download up to 1 million rows of query and analysis results at a time, with a data volume not exceeding 2 GiB. If the limit is exceeded, only the first 1 million rows or 2 GiB of data are downloaded.​
​
Request instructions​
  • Request method: POST​
  • Request URL: https://{tls-endpoint}/CreateDownloadTask​
Request parameters​
The table below lists only request parameters specific to this API and some common parameters. For more information, see Public parameters.​
Body​
​
Parameters​
Type​
Required​
Example value​
Description​
TaskName​
String​
Yes​
test-download-task​
Download task name. Length must be between 1 and 63 characters.​
TopicId​
String​
Yes​
3***********​
The ID of the TLS topic where the log is located.​
Query​
String​
No​
*​
Analyze query statement, up to 4 KiB in length.​
  • Supports specifying only the query statement. For example, setting it as * downloads all raw logs within the selected time range.​
StartTime​
Integer​
Yes​
1658332800000​
The query start time, accurate to milliseconds. Unix timestamp format, representing the number of milliseconds since 1970-01-01 00:00:00 UTC.​
EndTime​
Integer​
Yes​
1658332800000​
Query end time, accurate to milliseconds. Unix timestamp format, representing the number of milliseconds since 1970-01-01 00:00:00 UTC.​
DataFormat​
String​
Yes​
csv​
Export file format, supported settings:​
  • csv: CSV format​
  • json: JSON format​
  • jsonl: JSONL format​
Sort​
String​
No​
asc​
Sort order of logs when only querying without analysis.​
  • asc: Ascending order​
  • desc: Descending order​
Limit​
Integer​
No​
100​
Number of original log entries downloaded or number of rows in the analysis result Data volume must comply with download task limits For details, see User Guide​
Compression​
String​
Yes​
gzip​
Compression format of the exported file​
  • none: No compression.​
  • We recommend using the no-compression option only for smaller data volumes​
  • gzip: Compress using gzip format​
  • zip: Compress using zip format​
AllowIncomplete​
Boolean​
No​
false​
Allow downloading logs with imprecise query results.​
  • true: Allowed.​
  • false: Not allowed.​
TaskType​
Integer​
Yes​
0​
Type of log to download.​
  • 0: Download logs of the query type.​
  • 1: Download logs of the analysis type.​
  • 2: Download logs of the context type.​
LogContextInfos​
Object of LogContextInfos​
No​
/​
Download the log information required for query context, including the source host, the LogGroup ID, and the Serial number in the LogGroup.​
This parameter is required when TaskType is 2.​
​
LogContextInfos​
​
Parameters​
Type​
Required​
Example value​
Description​
Source​
String​
No​
127.10.10.**​
The host where the logs originate.​
You can obtain this value in the Logs field of the response from the SearchLogs API.​
ContextFlow​
String​
No​
e61050c-f7b3a4bf-2​
Specify the LogGroup ID where the log is located.​
This value can be found in Logs in the response from the SearchLogs API.​
PackageOffset​
Long​
No​
66​
Specifies the Serial number of the log in the LogGroup.​
You can get this value from the Logs section in the response of the SearchLogs API.​
​
Response parameters​
The table below lists only response parameters specific to this API. For more information, see Response structure.​
​
Parameters​
Type​
Example value​
Description​
TaskId​
String​
3***********​
Log topic ID.​
​
Sample request​
​
POST https://{tls-endpoint}/CreateDownloadTask HTTP/1.1​
Content-Type: application/json​
{​
"TaskName": "test-download-task",​
"TopicId": "3***********",​
"Query": "*",​
"StartTime": 1658332800000,​
"EndTime": 1658332800000,​
"DataFormat": "csv",​
"Sort": "asc",​
"Limit": 100,​
"Compression": "gzip",​
"AllowIncomplete": false,​
"TaskType": 0​
}​
}​
​
Sample response​
​
HTTP/1.1 200 OK​
Content-Type: application/json​
Content-Length: 0​
{​
"TaskId": "989b1f8d-13e6-4b14-819d-1a436377****"​
}​
​
Error Code​
The table below lists error codes related to this interface and its business logic. For public error codes, see the Public Error Code documentation.​
​
HTTP status code​
Error Code​
Error message​
Description​
400​
InvalidArgument​
Invalid argument key %s, value %s, please check argument.​
Invalid parameter.​
409​
ErrDownloadTaskAlreadyExists​
Download task already exist​
The download task already exists. A download task with the same name already exists in this region.​
500​
InternalServerError​
We encountered an unexpected server error, please try again later.​
Internal server error.​
​
Last updated: 2025.12.31 11:16:32