Lightweight

Kịch bản 1 Single receiver -> Single exporter

Hướng dẫn viết cấu hình thu thập dữ liệu từ một nguồn log duy nhất trên máy chủ và đẩy thẳng về một điểm nhận của hệ thống.

Tổng quan

Đây là mô hình thiết lập cơ bản và đơn giản nhất trong cấu hình Lightweight Sensor. Cấu hình này được áp dụng khi người dùng chỉ cần thu thập dữ liệu từ một nguồn log duy nhất trên máy chủ và chuyển thẳng về một điểm nhận duy nhất trên hệ thống để xử lý.

Cấu hình chi tiết

1. Receivers (Bộ nhận) - 1 nguồn

Phần này định nghĩa nguồn log cần thu thập.

receivers:
  filelog:
    include:
      - /var/log/syslog        # Collect từ file syslog
    start_at: end              # Bắt đầu từ cuối file (bỏ qua lịch sử)
    include_file_path: false   # Không thêm đường dẫn file vào log
    include_file_name: false   # Không thêm tên file vào log

Giải thích các tham số:

Tham sốMô tảGiá trị phổ biến
includeĐường dẫn file cần collect/var/log/syslog, /var/log/auth.log
start_atVị trí bắt đầu đọc fileend (cuối) hoặc beginning (đầu)
include_file_pathThêm đường dẫn file vào mỗi logtrue hoặc false
include_file_nameThêm tên file vào mỗi logtrue hoặc false

2. Processors (Bộ xử lý)

Đọc chi tiết

3. Exporters (Bộ gửi) - nhiều điểm đến

Phần này định nghĩa nơi gửi log (destination).

exporters:
  otlphttp:                                    # Exporter sử dụng giao thức OTLP HTTP
    endpoint: ${OTLP_ENDPOINT}                 # URL endpoint data connection
    logs_endpoint: ${OTLP_ENDPOINT}            # URL endpoint data connection
    logs_endpoint: ${OTLP_ENDPOINT}         
    headers:
      x-api-key: ${OTLP_API_KEY}               # API key xác thực
      Content-Type: "application/json"        # Định dạng dữ liệu
    timeout: 30s                               # Timeout kết nối
    encoding: json                             # Mã hóa dữ liệu

Giải thích các tham số:

Tham sốMô tả
endpointĐịa chỉ URL của Platform (ví dụ: https://platform.example.com:4317)
x-api-keyToken xác thực từ Platform
timeoutThời gian chờ kết nối (mặc định 30 giây)
encodingĐịnh dạng dữ liệu (json hoặc protobuf)

4. Extension & service

Đọc chi tiết

Ví dụ thực tế

receivers:
  filelog:
    include:
      - /var/log/syslog
    start_at: end
    include_file_path: true
    include_file_name: false

processors:
  batch:
    send_batch_size: 1
    send_batch_max_size: 1

exporters:
  otlphttp:
    endpoint: https://secops.company.com:4317
    logs_endpoint: https://secops.company.com:4317
    headers:
      x-api-key: sk_live_abc123def456
      Content-Type: "application/json"
    timeout: 30s
    encoding: json

service:
  pipelines:
    logs:
      receivers: [filelog]
      exporters: [otlphttp]