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

Torch Log Service

Copy page
Download PDF
Topic management API
CreateTopic
Copy page
Download PDF
CreateTopic
Call the CreateTopic API to create a log topic​
Usage instructions​
  • Before creating a log topic, make sure you have already created a project For more details, refer to CreateProject​
  • This API is limited to 20 requests per second. If the frequency exceeds the limit, an ExceedQPSLimit error will be returned​
Request instructions​
  • Request method: POST​
  • Request URL: https://{tls-endpoint}/CreateTopic​
Request parameters​
The table below lists only the unique request parameters for this API and some common parameters For more information, see common parameters​
Body​
​
Parameter​
Type​
Required​
Example value​
Description​
TopicName​
String​
Yes​
test-topic​
Log topic name. Please refer to the resource naming rules for naming conventions.​
ProjectId​
String​
Yes​
c7***********​
The ID of the project to which the log topic belongs.​
Ttl​
Integer​
Yes​
1300​
The total retention period for logs in TLS. Expired logs in this topic are automatically deleted after the specified log storage period. Unit: days. Default is 30 days. Range: 1 to 3650 days. 3650 days indicates permanent storage.​
tip​
After setting EnableHotTtl to true, the Ttl duration must match the total value of HotTtl, ColdTtl, and ArchiveTtl.​
ShardCount​
Integer​
Yes​
2​
The number of log shards. By default, 1 shard is created. The value ranges from 1 to 10 Each shard provides write capacity of 5 MiB/s and 500 times/s, and read capacity of 20 MiB/s and 100 times/s Plan the number of shards reasonably when creating a log topic. The number of shards cannot be changed after creation​
AutoSplit​
Boolean​
No​
true​
Automatic sharding can be enabled or disabled.​
  • true: When the data volume written exceeds the service capacity of existing shards for five consecutive minutes, TLS automatically splits shards based on data volume to meet business needs. However, the total number of shards after splitting cannot exceed the maximum allowed. New shards created within the last 15 minutes will not split automatically.​
  • false: Auto split for shards is disabled.​
MaxSplitShard​
Integer​
No​
50​
Maximum number of shard splits, i.e., the maximum number of partitions after splitting. The value range is 1 to 256, and the default value is 256.​
tip​
  • This is required only when Automatic sharding is enabled, that is, when AutoSplit is set to true.​
  • MaxSplitShard must be greater than the specified ShardCount. Otherwise, TLS cannot split shards automatically.​
EnableTracking​
Boolean​
No​
false​
WebTracking can be enabled or disabled. If enabled, you can quickly collect frontend tracking data through it.​
  • true: Enables WebTracking.​
  • false: (default) Disables WebTracking.​
tip​
After enabling WebTracking for a log topic, data written through the WebTracks API no longer needs authentication. This grants anonymous write access over the public network, but it may result in dirty data. For details, see Collect logs by using WebTracking.​
Description​
String​
No​
This is a test topic.​
Log topic description.​
  • Does not support <>,'、\, \\, or any emoji characters.​
  • Length: 0 to 64 characters.​
Tags​
Array of Tag​
No​
[{"Key":"key1", "Value":"value1"}]​
Log topic tag information.​
​
Tags identify and classify cloud resources. You can categorize log projects and topics by tags to facilitate resource search and aggregation. For details, see tag management.​
LogPublicIP​
Boolean​
No​
false​
Enable or disable the function to record extranet IP addresses. By default, it is enabled. When enabled, TLS automatically adds the following metadata fields to log entries.​
  • __tag____client_ip__: the public IP address of the device where the log originates. When writing log data using the private domain of TLS, the private IP address is recorded.​
  • __tag____receive_time__: the time the log reaches the server, formatted as a 10-digit Unix timestamp.​
tip​
When logs are written via WebTracking, TLS records public IP address of source device through clientAddr.​
EnableHotTtl​
Boolean​
No​
false​
Enable hierarchical storage. Once enabled, TLS supports standard storage, infrequent storage, and archive storage.​
After setting HotTtl, ArchiveTtl, and ColdTtl, if data is stored longer than the specified period, it is automatically moved to infrequent or archive storage for subsequent retention until the total log collection duration reaches the Ttl period, when it is automatically cleared by the backend.​
tip​
  • Archive storage is a beta feature. If you have relevant need, contact your account manager for allowlist access.​
  • Ttl must match the total value of HotTtl, ColdTtl, and ArchiveTtl.​
HotTtl​
Integer​
No​
30​
Standard storage duration. The default duration is 30 days, and the value range is 7 to 3650.​
This parameter takes effect only when EnableHotTtl is set to true.​
ColdTtl​
Integer​
No​
30​
Low-frequency storage duration. The range for this duration is 1–3650.​
Low-frequency storage is available for standard storage periods of 7 days or longer​
This parameter is effective only when EnableHotTtl is set to true​
ArchiveTtl​
Integer​
No​
60​
Archive storage duration. The valid range for this duration is 60 to 3650.​
Archive storage can be enabled when any of the following conditions are met.​
  • Standard storage duration is 30 days or longer.​
  • Standard storage duration is at least 7 days, and infrequent access storage is at least 30 days.​
This parameter is effective only when EnableHotTtl is set to true.​
​
Tag​
​
Parameter​
Type​
Required​
Example value​
Description​
Key​
String​
No​
owner​
Value of the label key. Refer to tag setting rules for configuration guidelines.​
Value​
String​
No​
zhangsan​
Tag Value. For configuration guidelines, refer to tag setting rules.​
​
Return parameters​
The table below lists only the unique return parameters for this API For more information, see response structure​
​
Parameter​
Type​
Example value​
Description​
TopicId​
String​
b***********​
Log topic ID.​
​
Sample request​
​
POST https://{tls-endpoint}/CreateTopic HTTP/1.1​
Content-Type: application/json​
{​
"ProjectId": "c7************",​
"TopicName": "test-topic",​
"Ttl": 30,​
"Description": "xxxxxx",​
"ShardCount": 1,​
"AutoSplit": true,​
"MaxSplitShard": 50,​
"EnableTracking": false,​
"Tags": [​
{​
"Key": "key1",​
"Value": "value1"​
}​
]​
}​
​
Sample response​
​
HTTP/1.1 200 OK​
Content-Type: application/json; charset=utf-8​
{​
"TopicId": "bcb************"​
}​
​
Error Code​
The table below lists error codes related to this interface and its business logic For general error codes, see the General Error Codes documentation​
​
HTTP status code​
Error Code​
Error message​
Description​
400​
InvalidArgument​
Invalid argument key %s, value %s, please check argument.​
Invalid parameter.​
400​
TopicQuotaExceed​
Topic Quota Exceed.​
Exceeded the quota for log topics​
409​
TopicAlreadyExist​
Topic xxx already exist.​
The log topic already exists.​
500​
InternalServerError​
We encountered an unexpected server error, please try again later.​
Internal server error.​
​
Last updated: 2025.10.28 18:41:13