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

MeshAccessLog로 여러 백엔드에 로깅하기

원문 보기 위키 갱신

MeshAccessLog로 여러 백엔드에 로깅하기 (MeshAccessLogs: Logging to multiple backends)

이 문서에서는 MeshAccessLog 정책 하나로 TCP, 파일, OpenTelemetry 세 가지 백엔드에 동시에 로그를 기록하는 방법을 알려줘요. Kubernetes, Universal, Terraform 환경별 설정 예시가 모두 준비되어 있어서 자신의 환경에 맞게 바로 따라 할 수 있어요. 각 백엔드마다 Json이나 Plain 같은 로그 형식과 속성을 다르게 지정하는 방법도 함께 확인할 수 있어요

출처: 문서

본문

여러 백엔드에 로깅하기

이 구성은 TCP, 파일, OpenTelemetry 세 가지 백엔드에 로그를 기록해요.

구성

Kubernetes

apiVersion: kuma.io/v1alpha1
kind: MeshAccessLog
metadata:
  name: multiple-backends
  namespace: kuma-demo
  labels:
    kuma.io/mesh: default
spec:
  rules:
  - default:
      backends:
      - type: Tcp
        tcp:
          address: 127.0.0.1:5000
          format:
            type: Json
            json:
            - key: start_time
              value: "%START_TIME%"
      - type: File
        file:
          path: "/dev/stdout"
          format:
            type: Plain
            plain: "[%START_TIME%]"
      - type: OpenTelemetry
        openTelemetry:
          endpoint: otel-collector:4317
          body:
            kvlistValue:
              values:
              - key: mesh
                value:
                  stringValue: "%KUMA_MESH%"
          attributes:
          - key: start_time
            value: "%START_TIME%"

Universal

type: MeshAccessLog
name: multiple-backends
mesh: default
spec:
  rules:
  - default:
      backends:
      - type: Tcp
        tcp:
          address: 127.0.0.1:5000
          format:
            type: Json
            json:
            - key: start_time
              value: "%START_TIME%"
      - type: File
        file:
          path: "/dev/stdout"
          format:
            type: Plain
            plain: "[%START_TIME%]"
      - type: OpenTelemetry
        openTelemetry:
          endpoint: otel-collector:4317
          body:
            kvlistValue:
              values:
              - key: mesh
                value:
                  stringValue: "%KUMA_MESH%"
          attributes:
          - key: start_time
            value: "%START_TIME%"

Terraform

현재 구성에 맞게 konnect_mesh_control_plane.my_meshcontrolplane.id와 konnect_mesh.my_mesh.name을 조정하세요. {: .text-sm}

resource "konnect_mesh_access_log" "multiple_backends" {
  provider = konnect-beta
  type = "MeshAccessLog"
  name = "multiple-backends"
  spec = {
    rules = [
      {
        default = {
          backends = [
            {
              type = "Tcp"
              tcp = {
                address = "127.0.0.1:5000"
                format = {
                  type = "Json"
                  json = [
                    {
                      key = "start_time"
                      value = "%START_TIME%"
                    }
                  ]
                }
              }
            },
            {
              type = "File"
              file = {
                path = "/dev/stdout"
                format = {
                  type = "Plain"
                  plain = "[%START_TIME%]"
                }
              }
            },
            {
              type = "OpenTelemetry"
              open_telemetry = {
                endpoint = "otel-collector:4317"
                body = {
                  kvlist_value = {
                    values = [
                      {
                        key = "mesh"
                        value = {
                          string_value = "%KUMA_MESH%"
                        }
                      }
                    ]
                  }
                }
                attributes = [
                  {
                    key = "start_time"
                    value = "%START_TIME%"
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
  labels   = {
  "kuma.io/mesh" = konnect_mesh.my_mesh.name
  }
  cp_id    = konnect_mesh_control_plane.my_meshcontrolplane.id
  mesh     = konnect_mesh.my_mesh.name
}

관련 리소스

더 알아보기 (Learn more)