# Create ULS Log Collection Configuration - CreateUK8SULSConfig

## Overview

Create a LogConfig custom resource to declaratively define log collection rules.






## Definition

### Public Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Action**     | string  | Corresponding API command name, the current API is `CreateUK8SULSConfig`.                      | **Yes** |
| **PublicKey**  | string  | The user's public key can be obtained from [Console](https://console.zosoc.com/uaccount/api_manage)                                             | **Yes** |
| **Signature**  | string  | User signature generated based on public key and API command, see [Signature Algorithm](/docs/api/summary/signature.md)  | **Yes** |

### Request Parameters

| Parameter Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **Region** | string | Region. See [Region and Zone List](/docs/api/summary/regionlist) |**Yes**|
| **Zone** | string | Zone. See [Region and Zone List](/docs/api/summary/regionlist) |**Yes**|
| **ProjectId** | string | Project ID. Leave it blank for the default project. Sub-accounts must fill in. Please refer to the [GetProjectList API](/docs/api/summary/get_project_list) |No|
| **TopicID** | string | The target Topic ID in ULS for receiving logs. |**Yes**|
| **ClusterId** | string | The UK8S cluster ID. |**Yes**|
| **Name** | string | The name of the log collection rule to create. The name must be unique and cannot exceed 253 characters. It can contain only lowercase letters (a-z), digits (0-9), hyphens (-), and dots (.). It must start and end with a lowercase letter or digit, and cannot start or end with a hyphen or dot. Consecutive dots or hyphens are not allowed. |**Yes**|
| **ExtractRule.LogType** | string | The log parsing type, which determines how logs are structured. Valid values: multi_line_delimiter (multiline delimiter), delimiter (delimiter), full_regex (full regex), multi_line_full_regex (multiline full regex), minimal_list (single-line plain text), and multi_line (multiline plain text). |**Yes**|
| **ExtractRule.CollectPolicy** | string | The log collection policy. Valid values: full (collect existing logs from the beginning) and increment (collect only logs generated from the current point in time). Default: full. |No|
| **ExtractRule.Encode** | string | The encoding format of the original log content. Valid values: utf-8 and gbk. Default: utf-8. |No|
| **ExtractRule.Keys.N** | string | Available when LogType is set to a delimiter, regex, or multiline regex parsing mode. |No|
| **ExtractRule.Delimiter** | string | The delimiter used when LogType is delimiter. Supported values: space, tab, \|, ;, and ,. |No|
| **ExtractRule.BeginningRegex** | string | The regular expression used to identify the beginning of a new log entry. It is applicable when LogType is a multiline mode, such as multi_line or multi_line_full_regex. |No|
| **ExtractRule.LogRegex** | string | The regular expression used to extract fields from logs. It is applicable when LogType is a regex-based mode, such as full_regex or multi_line_full_regex. |No|
| **ExtractRule.ExtractRule.LogRegexBase64** | string | The Base64-encoded regular expression used to extract fields from logs. |No|
| **ExtractRule.TimeKey** | string | The name of the field that contains the log timestamp when parsing JSON logs or logs using regular expressions. |No|
| **ExtractRule.TimeFormat** | string | The time format corresponding to the field specified by TimeKey. |No|
| **ExtractRule.UnMatchUpload** | string | Specifies whether to upload logs that fail to be parsed. true indicates that unmatched logs are uploaded, and false indicates that they are discarded. Default: false. |No|
| **ExtractRule.UnMatchKey** | string | No default value is provided. This field is required when UnMatchUpload is set to true. |No|
| **ExtractRule.DelimiterBase64** | string | The Base64-encoded delimiter. This field takes precedence over Delimiter. |No|
| **ExtractRule.BeginningRegexBase64** | string | The Base64-encoded regular expression used to identify the beginning of a new log entry. This field takes precedence over BeginningRegex. |No|
| **InputDetail.Type** | string | The log input type. Supported values: container_file and container_stdout. |**Yes**|
| **InputDetail.Metadata.Container** | string | Specifies the container metadata fields to collect. If left empty, container metadata is not collected. Supported fields: container_name, namespace, pod_name, pod_ip, pod_uid, container_id, and image_name. Pod label metadata can be configured through InputDetail.Metadata.Labels. |No|
| **InputDetail.Metadata.Labels** | string | Specifies which Pod labels to collect. Valid values: * (collect all labels), "app,version" (collect only the app and version labels), and "" (do not collect any labels). |No|
| **InputDetail.FilePaths.N.Path** | string | The path from which logs are collected. |No|
| **InputDetail.FilePaths.N.File** | string | The name of the log file to collect. |No|
| **InputDetail.Stream** | string | The container output stream to collect. Valid values: all, stdout, and stderr. Default: all. This field is applicable when InputDetail.Type is container_stdout. |No|
| **MatchRule.ContainerOperator** | string | The operator used to match container names. Supported values: in (include) and notin (exclude). |No|
| **MatchRule.Container** | string | The container names to match. Use * to match all containers. Multiple container names must be separated by commas. |No|
| **MatchRule.Workloads.N.Namespace** | string | The namespace of the workload when matching logs by workload. |No|
| **MatchRule.Workloads.N.Type** | string | The workload type when matching logs by workload, such as deployment, statefulset, daemonset, job, or cronjob. |No|
| **MatchRule.Workloads.N.Name** | string | The workload name when matching logs by workload. |No|
| **MatchRule.PodLabels.NamespaceOperator** | string | The operator used to include or exclude namespaces. Valid values: in and notin. |No|
| **MatchRule.PodLabels.Namespace** | string | The namespace name. |No|
| **MatchRule.PodLabels.Labels.N.Key** | string | The Pod label key to match when matching logs by Pod labels. |No|
| **MatchRule.PodLabels.Labels.N.ValueOperator** | string | The operator used to match Pod label values. Valid values: in and notin. |No|
| **MatchRule.PodLabels.Labels.N.Value** | string | The Pod label value to match when matching logs by Pod labels. |No|

### Response Field

| Field Name | Type | Description Information | Required |
|:---|:---|:---|:---|
| **RetCode** | int | Return status code. If it is 0, it means successful return. If it is not 0, it means failure. |**Yes**|
| **Action** | string | Operation command name. |**Yes**|
| **Message** | string | Returns an error message, providing detailed description when `RetCode` is non-zero. |No|




## Example

### Request Example
    
```
https://api.zosoc.com/?Action=CreateUK8SULSConfig
&Region=cn-zj
&Zone=cn-zj-01
&ProjectId=mTnJmhCk
&TopicID=cqGyMBwY
&ClusterId=lPgkrLoJ
&Name=enInlmdd
&ExtractRule.CollectPolicy=QphbYQti
&ExtractRule.Encode=RuByGGvP
&ExtractRule.LogType=vYDqTxpK
&ExtractRule.Delimiter=IxmsBKsf
&ExtractRule.BeginningRegex=IxBhFvBs
&ExtractRule.LogRegex=pligMTOZ
&ExtractRule.TimeKey=mOJXezrH
&ExtractRule.TimeFormat=QmwFYCWv
&ExtractRule.UnMatchKey=LdqdHiQH
&InputDetail.Type=TvAAKaZP
&InputDetail.Metadata.Container=goOfNbDg
&InputDetail.Metadata.Labels=kRJiYEVE
&InputDetail.FilePaths.N.Path=VibkGFGP
&InputDetail.FilePaths.N.File=HgHAjDVy
&MatchRule.ContainerOperator=scACWcjc
&MatchRule.Container=CLAdBtkp
&MatchRule.Workloads.N.Namespace=uqEDfRoq
&MatchRule.Workloads.N.Type=lOlATquw
&MatchRule.Workloads.N.Name=mpUqyauJ
&MatchRule.PodLabels.Labels.N.Key=JCcfOwru
&MatchRule.PodLabels.Labels.N.ValueOperator=GToTTBYN
&MatchRule.PodLabels.Labels.N.Value=jParVLLk
&ExtractRule.Keys.N=nJoumoAU
&MatchRule.PodLabels.NamespaceOperator=kLXDvrHF
&MatchRule.PodLabels.Namespace=mDUOTtSy
&ExtractRule.DelimiterBase64=IlmwgKSc
&ExtractRule.BeginningRegexBase64=zShzqdlg
&InputDetail.Stream=qdJuMqDK
&ExtractRule.ExtractRule.LogRegexBase64=bTzjHNBB
```

### Response Example
    
```json
{
  "Action": "CreateUK8SULSConfigResponse",
  "RetCode": 0
}
```





