To create a log collection configuration using a ClusterAliyunPipelineConfig, you must define the collection rules in a structured YAML file. This topic describes the structure of the YAML file and its fields.
The Custom Resource (CR) is the source of truth for collection configurations created using a CustomResourceDefinition (CRD). Do not modify these configurations in the Simple Log Service console. Any changes made in the console will be overwritten by the CR, which can cause data format errors or data loss.
How it works
Create a CR: Define collection rules in a
ClusterAliyunPipelineConfigYAML file and then submit the file using kubectl.Controller monitors changes: The loongcollector-operator continuously monitors CRs in the cluster for changes.
Sync configuration: When a change to a CR is detected, the operator converts the CR into a specific configuration and submits it to the specified project.
Collector pulls the latest configuration: The loongcollector-ds periodically sends heartbeats to Simple Log Service to pull the latest collection configuration and then hot-reloads it.
Start collection and reporting: The loongcollector-ds collects logs based on the latest configuration and sends the logs to SLS using the configured endpoint.
Basic fields
All configurations must start by defining the API version and resource type as follows:
apiVersion: telemetry.alibabacloud.com/v1alpha1
kind: ClusterAliyunPipelineConfigStructure example
apiVersion: telemetry.alibabacloud.com/v1alpha1 # Use the default value. Do not modify.
kind: ClusterAliyunPipelineConfig # Use the default value. Do not modify.
metadata:
name: test-config # Set the resource name. It must be unique within the current Kubernetes cluster.
spec:
project: # Set the name of the destination project.
name: k8s-your-project
config: # Set the Logtail collection configuration.
inputs: # Set the input plugins for the Logtail collection configuration.
...
flushers: # Set the output plugins for the Logtail collection configuration.
...Core parameter descriptions
metadata.name
The name of the collection configuration. This parameter is required. The name must be unique within the project and cannot be changed after creation.
Naming convention:
| Example: |
spec.project
Specifies the target project.
The project field cannot be changed after the CR is created. To switch to a different project, you must create a new CR.
Parameter | Data type | Required | Description |
name | string | Yes | The name of the destination project. If the project does not exist, it is automatically created. |
description | string | No | The description of the project. This parameter takes effect only when the project is created. |
endpoint | string | No | The endpoint of the region where the project is located. The default value is the region of the cluster.
|
uid | string | No | The UID of the Alibaba Cloud account to which the destination project belongs. The default value is the UID of the Alibaba Cloud account to which the current cluster belongs.
|
spec.config
Specifies the main body of the collection configuration, which defines the input, processing, and output plugins.
Sub-field | Type | Required | Description |
| string | No | A log sample. You can provide multiple logs. The total length cannot exceed 1,500 bytes. |
| object | No | |
| List of objects | Yes | A list of input plugins. Currently, only one input plugin is allowed. |
| List of objects | No | A list of processing plugins: |
| List of objects | Yes | A list of output plugins. Currently, only one |
spec.logstores
Optional. Declares the Logstores that you want to create automatically. Note the following:
Effective only on creation: All parameters except for
nameapply only when a Logstore is created. If the Logstore already exists, the system ignores these settings and does not modify the existing properties of the Logstore.Does not determine the data destination: This list does not determine the destination Logstore for the logs. The actual destination is determined by the output plugin in
config.flushers, such asflusher_sls.Optional configuration: If the destination Logstore already exists, you do not need to include it in this configuration.
Supports only add and delete operations: You can add new Logstores to the list or remove items from it. However, you cannot modify this configuration to change the properties of an existing Logstore, such as its TTL or shard count. To modify these properties, you must use the console or an API operation.
Parameter | Data type | Required | Description |
name | string | Yes | The name of the Logstore to create. |
queryMode | string | No | Logstore specifications. The default value is
|
ttl | int | No | The data retention period in days. Valid values: 1 to 3650. The default value is 30. A value of 3650 indicates permanent storage. |
hotTtl | int | No | The hot data storage period in days. The default value is 0. The value must be less than ttl and greater than or equal to 7. |
infrequentAccessTTL | int | No | The infrequent access storage period for the target Logstore, in days. The default value is 0. `hotTtl` must be specified, and the value of this parameter must be less than `ttl` and greater than or equal to 30. If `hotTtl` + `infrequentAccessTTL` is not equal to `ttl`, the value of |
shardCount | int | No | The number of shards. The default value is 2. Valid values: 1 to 100. |
maxSplitShard | int | No | The maximum number of shards that can be automatically split. The default value is 64. Valid values: 1 to 256. |
autoSplit | bool | No | Specifies whether to enable automatic sharding. The default value is true. |
telemetryType | string | No | The type of observable data. The default value is None. Valid values:
|
appendMeta | bool | No | Specifies whether to record the public IP address and the log reception time. The default value is true.
|
enableTracking | bool | No | Specifies whether to enable the web tracking feature. The default value is false. |
encryptConf | object | No | The encryption configuration data structure. It contains the |
meteringMode | string | No | Billing mode. For more information, see Manage a Logstore. This field is empty by default. Valid values:
Note A Logstore with `queryMode` set to `query` supports only the pay-by-feature billing mode. If pay-by-ingested-data is not enabled for your account, you cannot set this parameter to ChargeByDataIngest. |
index | object | No | The index configuration. This parameter applies only when the Logstore is created. For the format, see the general data format for index. This parameter is available only when the loongcollector-operator component version is 1.0.6 or later. |
spec.machineGroups
Specifies the machine groups that can use this collection configuration.
Default behavior: When LoongCollector is installed, the system automatically creates a machine group named
k8s-group-${clusterId}. If you do not explicitly specify themachineGroupsparameter, this collection configuration is associated with that machine group by default.Synchronization mechanism: The
loongcollector-operatorensures that the machine groups associated with the collection configuration strictly match the list defined inmachineGroups. The system automatically disassociates any machine group that is not in this list.Automatic creation support: If a specified machine group does not exist, the system automatically creates an identifier-based machine group with the same name and attaches it to the current collection configuration.
Parameter | Data type | Required | Description |
name | string | No | The name of the machine group to associate. |
spec.enableUpgradeOverride
Optional. Specifies whether the system can overwrite previous configurations. You can use this parameter to resolve conflicts between different versions of collection configurations. The default value is false.
true: Theloongcollector-operatoroverwrites and upgrades the existing collection configuration defined by AliyunLogConfig.false: If a conflict exists in the collection configuration, applying the AliyunPipelineConfig fails.
Scenario: A conflict occurs if an AliyunLogConfig resource that defines a collection configuration already exists in the cluster, and you attempt to apply an AliyunPipelineConfig that references the same collection configuration.
Definition of the same collection configuration:
Same project
AliyunLogConfig: Uses the cluster's default project orspec.project.AliyunPipelineConfig: Usesspec.project.name.
Same collection configuration name
AliyunLogConfig:spec.logtailConfig.configNameAliyunPipelineConfig:metadata.name
Upgrade process:
Apply the new configuration: Applying the
ClusterAliyunPipelineConfigupdates the collection configuration.Clean up the previous configuration: If the update is successful, the controller automatically deletes the corresponding
AliyunLogConfigresource from the cluster.Complete the migration: This completes the seamless transition from the old method to the new one.