Domain name for API request: cls.tencentcloudapi.com.
This API is used to create collection rule configuration.
A maximum of 30 requests can be initiated per second for this API.
The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.
Parameter Name | Required | Type | Description |
---|---|---|---|
Action | Yes | String | Common Params. The value used for this API: CreateConfig. |
Version | Yes | String | Common Params. The value used for this API: 2020-10-16. |
Region | No | String | Common Params. This parameter is not required for this API. |
Name | Yes | String | Collection configuration name |
Output | Yes | String | Log topic ID (TopicId) of collection configuration |
Path | No | String | Log collection path containing the filename |
LogType | No | String | The collected log type, default is minimalist_log. Supports the following types:- json_log: JSON File Log (For more information, see Using JSON pattern to collect logs);- delimiter_log: Delimiter - File Logs (For more information, see Using delimiter pattern to collect logs);- minimalist_log: Single-line Full-text File Log (For more information, see Using single-line full-text pattern to collect logs);- fullregex_log: Single line full regular expression - File log (For more information, see Using single-line - complete regular expression pattern to collect logs);- multiline_log: Multiline Full-text File Log (For more information, see Using multi-line full-text pattern to collect logs);- multiline_fullregex_log: Multi-line complete regular expression - File Logs (For more information, see Using multi-line - complete regular expression pattern to collect logs);- user_define_log: Combined parsing (Suitable for logs with multiple nested formats, see Using combined parsing pattern to collect logs);- service_syslog: syslog collection (For more information, see Collect Syslog);- windows_event_log: Windows event log (see Collecting Windows Event Logs). |
ExtractRule | No | ExtractRuleInfo | Extraction rule. If ExtractRule is set, LogType must be set. |
ExcludePaths.N | No | Array of ExcludePathInfo | Collection path blocklist |
UserDefineRule | No | String | Custom collection rules, serialized JSON string. Required when LogType is user_define_log. |
AdvancedConfig | No | String | Advanced collection configuration. A JSON string, Key/Value definition as follows:- ClsAgentFileTimeout (timeout property), value range: an integer greater than or equal to 0, where 0 means no timeout.- ClsAgentMaxDepth (maximum directory depth), value range: an integer greater than or equal to 0.- ClsAgentParseFailMerge (Merge Parsing Failure Log), value range: true or falseSample: {\"ClsAgentFileTimeout\":0,\"ClsAgentMaxDepth\":10,\"ClsAgentParseFailMerge\":true} Default placeholder value in console: {\"ClsAgentDefault\":0} |
Parameter Name | Type | Description |
---|---|---|
ConfigId | String | Collection configuration ID |
RequestId | String | The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem. |
FilterKeyRegex: Loglistener log filter rule list (earlier version), log keys that need to be filtered and their corresponding regex.
Note: For LogListener versions 2.9.3 and later, it's recommended to use the AdvanceFilterRules configuration for log filtering.
POST / HTTP/1.1
Host: cls.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateConfig
<Common request parameters>
{
"Name": "test2.8.8",
"Path": "/data/log/**/my.log",
"ExcludePaths": [],
"LogType": "minimalist_log",
"UserDefineRule": "",
"ExtractRule": {
"IsGBK": 0,
"FilterKeyRegex": [
{
"Key": "__CONTENT__",
"Regex": "400|500"
}
],
"Backtracking": 0,
"MetadataType": 0,
"MetaTags": [
{
"Key": "",
"Value": ""
}
],
"PathRegex": ""
},
"AdvancedConfig": "{\"ClsAgentFileTimeout\":0}",
"Output": "6bf3355c-3c88-4566-89c8-76c3ca37bae9"
}
{
"Response": {
"ConfigId": "a2c6342c-270a-4468-86cf-92625e468888",
"RequestId": "a21b16c1-4da9-45a1-a612-59e5757384f3"
}
}
This example shows you how to create combined parsing configuration.
POST / HTTP/1.1
Host: cls.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateConfig
<Common request parameters>
{
"Name": "my-test",
"Path": "/data/log/**/my.log",
"ExcludePaths": [],
"LogType": "user_define_log",
"UserDefineRule": "{\"processors\":[{\"type\":\"processor_split_delimiter\",\"detail\":{\"Delimiter\":\",\",\"ExtractKeys\":[\"time\",\"msg1\",\"msg2\"]},\"processors\":[{\"type\":\"processor_timeformat\",\"detail\":{\"KeepSource\":true,\"TimeFormat\":\"%s\",\"SourceKey\":\"time\"}},{\"type\":\"processor_split_delimiter\",\"detail\":{\"KeepSource\":false,\"Delimiter\":\"|\",\"SourceKey\":\"msg1\",\"ExtractKeys\":[\"submsg1\",\"submsg2\",\"submsg3\"]},\"processors\":[]},{\"type\":\"processor_split_key_value\",\"detail\":{\"KeepSource\":false,\"Delimiter\":\":\",\"SourceKey\":\"msg2\"}}]}]}",
"ExtractRule": {
"IsGBK": 0,
"FilterKeyRegex": [],
"UnMatchUpLoadSwitch": true,
"UnMatchLogKey": "LogParseFailure",
"Backtracking": 0,
"MetadataType": 2,
"MetaTags": [
{
"Key": "mryx",
"Value": "item"
}
],
"PathRegex": ""
},
"AdvancedConfig": "{\"ClsAgentFileTimeout\":3600}",
"Output": "6bf3355c-3c88-4566-89c8-76c3ca37bae9"
}
{
"Response": {
"ConfigId": "xxxx-xx-xx-xx-xxxxxxxx",
"RequestId": "6ef60bec-0242-43af-bb20-270359fb54a7"
}
}
This example shows you how to create collection rule configuration.
POST / HTTP/1.1
Host: cls.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateConfig
<Common request parameters>
{
"Name": "my-test-minimalist_log",
"Path": "/data/log/**/my.log",
"ExcludePaths": [
{
"Type": "File",
"Value": "/data/log/mryx/my.log"
}
],
"LogType": "minimalist_log",
"UserDefineRule": "",
"ExtractRule": {
"IsGBK": 0,
"FilterKeyRegex": [],
"Backtracking": 0,
"MetadataType": 2,
"MetaTags": [
{
"Key": "mryx",
"Value": "item"
},
{
"Key": "wd",
"Value": "shop"
}
],
"PathRegex": ""
},
"AdvancedConfig": "{\"ClsAgentMaxDepth\":10}",
"Output": "6bf3355c-3c88-4566-89c8-76c3ca37bae9"
}
{
"Response": {
"ConfigId": "b5a78efe-984c-47e2-99a8-52dbd1388888",
"RequestId": "037a6def-51d4-449b-a894-7cd2410bfae1"
}
}
POST / HTTP/1.1
Host: cls.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: CreateConfig
<Common request parameters>
{
"Name": "Single-line full regex - File log", "Path": "/data/log/**/my.log",
"ExcludePaths": [
{
"Type": "File",
"Value": "/data/log/my.log"
}
],
"LogType": "fullregex_log",
"UserDefineRule": "",
"ExtractRule": {
"IsGBK": 0,
"Be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keys": [
"Version",
"ConfigId"
],
"TimeKey": "log_time",
"TimeFormat": "%Y-%m-%d %H:%M:%S.%f",
"FilterKeyRegex": [
{
"Key": "key1",
"Regex": "value1"
},
{
"Key": "key2",
"Regex": "velue2"
}
],
"UnMatchUpLoadSwitch": true,
"UnMatchLogKey": "LogParseFailure",
"Backtracking": 10,
"MetadataType": 2,
"MetaTags": [
{
"Key": "mryx",
"Value": "item"
}
],
"PathRegex": ""
},
"AdvancedConfig": "{\"ClsAgentMaxDepth\":10,\"ClsAgentFileTimeout\":3600}",
"Output": "6bf3355c-3c88-4566-89c8-76c3ca37bae9"
}
{
"Response": {
"ConfigId": "8e63fe9a-5f36-49b0-bdbf-ab1c29e58888",
"RequestId": "420f4f07-2134-4167-9442-9ac6c6ffe3d8"
}
}
TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.
The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.
Error Code | Description |
---|---|
AuthFailure | CAM signature/authentication error. |
FailedOperation | Operation failed. |
InternalError | Internal error. |
InvalidParameter | Incorrect parameter. |
InvalidParameter.ConfigConflict | The same collection configuration rule already exists. |
InvalidParameterValue | Incorrect parameter value. |
LimitExceeded.Config | The collection rule configuration exceeds the maximum value limit. |
MissingParameter | Missing parameter. |
OperationDenied | Operation denied. |
OperationDenied.AccountDestroy | The account has been terminated. |
OperationDenied.AccountIsolate | The account has overdue payments. |
OperationDenied.AccountNotExists | The account does not exist. |
ResourceNotFound.ConfigNotExist | The specified collection rule configuration does not exist. |
ResourceNotFound.TopicNotExist | The log topic does not exist. |
Was this page helpful?