본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

OpenTelemetry 컬렉터

원문 보기 위키 갱신

OpenTelemetry 컬렉터 (OpenTelemetry Collector)

이 문서는 접근 로그 같은 비샘플링 로그를 OpenTelemetry 표준으로 수집해서 Metering & Billing로 전달하는 방법을 설명해요. otel_log 입력 플러그인으로 로그를 받고 bloblang으로 CloudEvents 형식에 맞게 매핑한 다음, 출력 설정으로 이벤트를 전송하는 전체 구성 과정을 단계별로 다뤄요. 사전 준비물부터 예제 사용 사례와 설치 방법까지 로그 기반 사용량 데이터를 활용하는 데 필요한 내용을 함께 확인할 수 있어요

출처: 문서

본문

샘플링되지 않은 로그(예: 액세스 로그)는 사용량 정보를 얻을 수 있는 훌륭한 원천이에요. 로그 전달을 위한 오픈 표준인 OpenTelemetry와 결합하면, 로그에서 사용량 정보를 추출해서 Metering & Billing으로 전달할 수 있어요.

전제 조건

OpenTelemetry 호환 로그 전송 솔루션이 필요해요. OpenTelemetry Collector로 시작할 수 있어요.

구성

먼저, 컬렉터 구성을 위한 새 YAML 파일을 만드세요. otel_log Redpanda Connect 입력을 사용하세요:

input:
  otel_log:
    # Point your log forwarder to this address using the OTLP gRPC protocol.
    address: 127.0.0.1:4317

참고: 이건 공식 Redpanda Connect 배포판에는 포함되지 않은 커스텀 입력 플러그인이에요. 플러그인의 소스 코드는 GitHub에서 찾을 수 있어요.

다음으로, bloblang을 사용해서 로그 스키마에서 CloudEvents로의 매핑을 구성하세요:

pipeline:
  processors:
    - mapping: |
        root = {
          "id": uuid_v4(),
          "specversion": "1.0",
          "type": "api-calls",
          "source": "otlp-log",
          "time": this.record.attributes.time,
          "subject": this.record.attributes.subject,
          "data": {
            "method": this.record.attributes.method,
            "path": this.record.attributes.path,
            "region": this.record.attributes.region,
            "zone": this.record.attributes.zone,
            "duration_ms": this.record.attributes.duration,
          },
        }

로그 속성 안내: this.record.attributes에는 otel_log 입력 플러그인이 추출한 로그 속성이 담겨 있어요.

마지막으로, 출력을 구성하세요:

output:
  label: 'openmeter'
  drop_on:
    error: false
    error_patterns:
      - Bad Request
  output:
    http_client:
      url: '${OPENMETER_URL:https://us.api.konghq.com}/v3/openmeter/events'
      verb: POST
      headers:
        Authorization: 'Bearer $KONNECT_SYSTEM_ACCESS_TOKEN'
        Content-Type: 'application/json'
      timeout: 30s
      retry_period: 15s
      retries: 3
      max_retry_backoff: 1m
      max_in_flight: 64
      batch_as_multipart: false
      drop_on:
        - 400
      batching:
        count: 100
        period: 1s
        processors:
          - metric:
              type: counter
              name: openmeter_events_sent
              value: 1
          - archive:
              format: json_array
      dump_request_log_level: DEBUG

$KONNECT_SYSTEM_ACCESS_TOKEN을 여러분만의 시스템 액세스 토큰으로 교체하세요.

예제 사용 사례

완전히 동작하는 예제는 GitHub에서 확인할 수 있어요.

설치

Metering & Billing Collector(커스텀 Redpanda Connect 배포판)는 다음과 같은 배포 방식으로 이용할 수 있어요:

  • 바이너리는 GitHub Releases 페이지에서 다운로드할 수 있어요.
  • 컨테이너 이미지는 ghcr.io에서 이용할 수 있어요.
  • Helm 차트도 GitHub Packages에서 이용할 수 있어요.

관련 리소스

더 알아보기 (Learn more)

  • 출력 설정의 Authorization 헤더에 사용할 시스템 액세스 토큰 발급 방법을 안내해요 — system access token
  • 수집한 로그 사용량 데이터를 확인하고 활용하는 Metering & Billing 기능을 소개해요 — Konnect Metering & Billing
  • Metering & Billing에서 사용할 수 있는 다른 수집기 옵션도 함께 살펴봐요 — Collectors