tencent cloud

All product documents
Cloud Log Service
CreateConfig
Last updated: 2024-04-15 19:58:42
CreateConfig
Last updated: 2024-04-15 19:58:42

1. API Description

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.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

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 false
Sample:{\"ClsAgentFileTimeout\":0,\"ClsAgentMaxDepth\":10,\"ClsAgentParseFailMerge\":true}

Default placeholder value in console: {\"ClsAgentDefault\":0}

3. Output Parameters

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.

4. Example

Example1 Creating Single-Line Full Text

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.

Input Example

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"
}

Output Example

{
    "Response": {
        "ConfigId": "a2c6342c-270a-4468-86cf-92625e468888",
        "RequestId": "a21b16c1-4da9-45a1-a612-59e5757384f3"
    }
}

Example2 Creating Combined Parsing Configuration

This example shows you how to create combined parsing configuration.

Input Example

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"
}

Output Example

{
    "Response": {
        "ConfigId": "xxxx-xx-xx-xx-xxxxxxxx",
        "RequestId": "6ef60bec-0242-43af-bb20-270359fb54a7"
    }
}

Example3 Creating Collection Rule Configuration

This example shows you how to create collection rule configuration.

Input Example

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"
}

Output Example

{
    "Response": {
        "ConfigId": "b5a78efe-984c-47e2-99a8-52dbd1388888",
        "RequestId": "037a6def-51d4-449b-a894-7cd2410bfae1"
    }
}

Example4 Creating Single-Line Full Regex - File Log

Input Example

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,
        "BeginRegex": "\\{\"\\w+\":\"\\w+\",\"\\w+\":\"\\w+\",\"\\w+\":\\{\"\\w+\"[^\"]+([^,]+),\"\\w+\":\"/\\w+/\\w+/\\*\\*/\\w+\\.\\w+\",\"\\w+\":\\[\\{\"\\w+\":\"\\w+\",\"\\w+\":\"/\\w+/\\w+/\\w+\\.\\w+\"\\}\\],\"\\w+\":\"\\w+\\.\\d+\\.\\d+\",\"\\w+\":\"\\w+\",\"\\w+\":\"\\w+\",\"\\w+\":\"\",\"\\w+\":\\{\"\\w+\":\\d+,\"\\w+\":\\[\\{\"\\w+\":\"\\w+\",\"\\w+\":\"\\d+\\|\\d+\"\\}\\],\"\\w+\":\\d+,\"\\w+\":\\d+,\"\\w+\":\\[\\{\"\\w+\":\"\\w+\",\"\\w+\":\"\\w+\"\\}\\],\"\\w+\":\"\",\"\\w+\":\\[\\]\\},\"\\w+\":\"\\{\\\\\"\\w+\\\\\":\\d+\\}\",\"\\w+\"[^\"]+([^\\}]+).*",
        "LogRegex": "\\{\"\\w+\":\"\\w+\",\"\\w+\":\"\\w+\",\"\\w+\":\\{\"\\w+\"[^\"]+([^,]+),\"\\w+\":\"/\\w+/\\w+/\\*\\*/\\w+\\.\\w+\",\"\\w+\":\\[\\{\"\\w+\":\"\\w+\",\"\\w+\":\"/\\w+/\\w+/\\w+\\.\\w+\"\\}\\],\"\\w+\":\"\\w+\\.\\d+\\.\\d+\",\"\\w+\":\"\\w+\",\"\\w+\":\"\\w+\",\"\\w+\":\"\",\"\\w+\":\\{\"\\w+\":\\d+,\"\\w+\":\\[\\{\"\\w+\":\"\\w+\",\"\\w+\":\"\\d+\\|\\d+\"\\}\\],\"\\w+\":\\d+,\"\\w+\":\\d+,\"\\w+\":\\[\\{\"\\w+\":\"\\w+\",\"\\w+\":\"\\w+\"\\}\\],\"\\w+\":\"\",\"\\w+\":\\[\\]\\},\"\\w+\":\"\\{\\\\\"\\w+\\\\\":\\d+\\}\",\"\\w+\"[^\"]+([^\\}]+).*",
        "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"
}

Output Example

{
    "Response": {
        "ConfigId": "8e63fe9a-5f36-49b0-bdbf-ab1c29e58888",
        "RequestId": "420f4f07-2134-4167-9442-9ac6c6ffe3d8"
    }
}

5. Developer Resources

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

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?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon