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

Torch Log Service

Copy page
Download PDF
Installation and upgrade
Install LogCollector (Sidecar deployment)
Copy page
Download PDF
Install LogCollector (Sidecar deployment)
This topic introduces how to install LogCollector in a Kubernetes cluster using Sidecar deployment.​
Background information​
LogCollector that is installed in Sidecar mode only supports collecting text logs from other containers within the same Pod. It does not support collecting container standard output or collecting text logs and standard output from containers in other pods.​
When creating collection rules, do not enable container log collection.​
The installation process includes the following steps:​
  1. Create a ConfigMap for LogCollector.​
  1. Create LogCollector Sidecar.​
Preparation​
The IAM user has been created, and the Access Key ID and Secret Access Key have been obtained. Besides, the user is granted at least the TLSLogCollectorAccess permission policy. For details about permissions, see IAM overview.​
Steps​
Log in to the Kubernetes cluster where LogCollector needs to be installed; install LogCollector using Sidecar deployment according to the following steps.​
1 Create Namespace​
Create a Namespace for LogCollector.​
  1. Create a YAML file named logcollector_ns.yaml.​
  • ​
    vim logcollector_ns.yaml​
    ​
  1. Enter the following content in the YAML file.​
  • ​
    apiVersion: v1​
    kind: Namespace​
    metadata:​
    name: <namespace>​
    ​
  • The parameters are described below:​
  • ​
    Parameters​
    Example value​
    Description​
    namespace​
    kube-system​
    Namespace name.​
    ​
  1. Run the following command to apply the Namespace configuration.​
  • ​
    kubectl apply -f logcollector_ns.yaml​
    ​
2 Create ConfigMap​
Create a ConfigMap for LogCollector.​
  1. Create a YAML file named logcollector_config.yaml .​
  • ​
    vim logcollector_config.yaml​
    ​
  1. Edit the YAML file and enter the following script in it.​
  • Configure the relevant parameters in the script based on actual needs.​
  • ​
    apiVersion: v1​
    kind: ConfigMap​
    metadata:​
    name: logcollector-config​
    namespace: <namespace>​
    data:​
    logcollector.yml: |​
    sidecar_mode: true​
    ​
    output:​
    tls:​
    region: <region>​
    endpoint: <endpoint>​
    secret_id: <secret_id>​
    secret_key: <secret_key>​
    label: <label>​
    ​
  • ​
  • The parameters are described below:​
  • ​
    Variable​
    Example value​
    Description​
    namespace​
    kube-system​
    Namespace. Enter the namespace you set in 1 Create Namespace.​
    region​
    cn-beijing​
    The region where the log project is located.​
    For TLS region and corresponding ID, see Service address list.​
    endpoint​
    https://tls-cn-beijing.ivolces.com​
    TLS connection domain, i.e., the service address.​
    Log in to TLS console, and you can view the connection domain name on the project details page. For more details, see Service address.​
    secret_id​
    AK********​
    Access Key ID for the VolcanoEngine main account or sub-account.​
    You can view and copy the Access Key ID on the VolcanoEngine console Key Management page.​
    secret_key​
    TUdZ********​
    Secret Access Key of the VolcanoEngine main account or sub-account.​
    You can view and copy the Secret Access Key on the VolcanoEngine console Key management page.​
    label​
    http_module​
    Label identifier for LogCollector.​
    • If you need to add this LogCollector to a host group of host identification type, the label parameter must be set. When creating a host group of Host identification type, set Host identification as the label. For details, see Host group overview.​
    • You can configure multiple label identifications; separate them by commas (,).​
    ​
  1. Run the following command to apply the ConfigMap configuration.​
  • ​
    kubectl apply -f logcollector_config.yaml​
    ​
3 Create Sidecar​
Create a Sidecar for LogCollector to collect text logs from other containers within the same Pod.​
  1. Create a YAML file named logcollector_sc.yaml. ​
  • ​
    vim logcollector_sc.yaml​
    ​
  1. Enter the following in the YAML file, and set the parameters based on your actual needs.​
  • ​
    apiVersion: v1​
    kind: Pod​
    metadata:​
    name: sidecar-demo​
    namespace: <namespace>​
    spec:​
    containers:​
    - name: generator​
    image: busybox:1.28​
    args:​
    - /bin/sh​
    - -c​
    - >​
    i=0;​
    while true;​
    do​
    echo "$i: $(date)" >> /var/log/foo.log;​
    i=$((i+1));​
    sleep 1;​
    done​
    volumeMounts:​
    - name: logs-dir​
    mountPath: /var/log​
    - name: logcollector​
    image: <image>​
    imagePullPolicy: Always​
    args:​
    - /usr/local/container/logcollector/logcollectord​
    - -c​
    - /usr/local/container/logcollector/etc/logcollector.yml​
    - --httpprof​
    - 0.0.0.0:6060​
    resources:​
    limits:​
    cpu: '2'​
    memory: 2Gi​
    requests:​
    cpu: '1'​
    memory: 1Gi​
    volumeMounts:​
    - name: logcollector-config​
    mountPath: /usr/local/container/logcollector/etc​
    readOnly: true​
    - name: logcollector-data​
    mountPath: /usr/local/container/logcollector/data​
    - name: logs-dir​
    mountPath: /var/log​
    env:​
    - name: "LOG_COLLECTOR_ENV_TAGS"​
    value: "__pod_name__|__pod_ip__|__namespace__|__node_name__|__node_ip__"​
    - name: "__pod_name__"​
    valueFrom:​
    fieldRef:​
    fieldPath: metadata.name​
    - name: "__pod_ip__"​
    valueFrom:​
    fieldRef:​
    fieldPath: status.podIP​
    - name: "__namespace__"​
    valueFrom:​
    fieldRef:​
    fieldPath: metadata.namespace​
    - name: "__node_name__"​
    valueFrom:​
    fieldRef:​
    fieldPath: spec.nodeName​
    - name: "__node_ip__"​
    valueFrom:​
    fieldRef:​
    fieldPath: status.hostIP​
    - name: MAX_MEM​
    valueFrom:​
    resourceFieldRef:​
    containerName: logcollector​
    resource: limits.memory​
    - name: MAX_PROCS​
    valueFrom:​
    resourceFieldRef:​
    containerName: logcollector​
    resource: limits.cpu​
    volumes:​
    - name: logcollector-config​
    configMap:​
    defaultMode: 420​
    name: logcollector-config​
    - name: logcollector-data​
    emptyDir: { }​
    - name: logs-dir​
    emptyDir: { }​
    ​
  • ​
    Variable​
    Example value​
    Description​
    namespace​
    kube-system​
    Namespace. Enter the namespace you set in 1 Create Namespace.​
    image​
    logcollector-cn-beijing.cr.volces.com/logcollector/logcollector:latest​
    LogCollector image address For the latest version of the LogCollector image address, see LogCollector image address.​
    ​
  • ​
​
  1. Run the following command to apply the configuration. Replace the file name as needed.​
  • ​
    kubectl apply -f logcollector_sc.yaml​
    ​
LogCollector image address​
The latest LogCollector image addresses provided by Torch log service (TLS) in each region are as follows:​
Replace the Region ID in the image address with the actual region ID for your environment. For example, the region ID for North China 2 (Beijing) is cn-beijing. For supported regions, see Service address list.​
​
logcollector-Region ID.cr.volces.com/logcollector/logcollector:latest​
​
​
Last updated: 2026.09.11 14:34:03