7.12. Loki로 로그 전달


내부 기본 OpenShift Container Platform Elasticsearch 인스턴스 대신 외부 Loki 로깅 시스템으로 로그를 전달할 수 있습니다.

Loki에 대한 로그 전달을 구성하려면 Loki에 대한 출력과 출력을 사용하는 파이프라인이 있는 ClusterLogForwarder 사용자 정의 리소스(CR)를 생성해야 합니다. Loki의 출력은 HTTP(비보안) 또는 HTTPS(보안 HTTP) 연결을 사용할 수 있습니다.

사전 요구 사항

  • CR의 url 필드로 지정하는 URL에서 Loki 로깅 시스템을 실행해야 합니다.

절차

  1. ClusterLogForwarder CR 오브젝트를 정의하는 YAML 파일을 생성하거나 편집합니다.

    apiVersion: "logging.openshift.io/v1"
    kind: ClusterLogForwarder
    metadata:
      name: instance 
    1
    
      namespace: openshift-logging 
    2
    
    spec:
      outputs:
       - name: loki-insecure 
    3
    
         type: "loki" 
    4
    
         url: http://loki.insecure.com:3100 
    5
    
       - name: loki-secure
         type: "loki"
         url: https://loki.secure.com:3100 
    6
    
         secret:
            name: loki-secret 
    7
    
      pipelines:
       - name: application-logs 
    8
    
         inputRefs: 
    9
    
         - application
         - audit
         outputRefs:
         - loki-secure 
    10
    
         loki:
           tenantKey: kubernetes.namespace_name 
    11
    
           labelKeys: kubernetes.labels.foo   
    12
    Copy to Clipboard Toggle word wrap
    1
    ClusterLogForwarder CR의 이름은 instance여야 합니다.
    2
    ClusterLogForwarder CR의 네임스페이스는 openshift-logging이어야 합니다.
    3
    출력 이름을 지정합니다.
    4
    유형을 "loki"로 지정합니다.
    5
    Loki 시스템의 URL 및 포트를 유효한 절대 URL로 지정합니다. http(비보안) 또는 https(보안 HTTP) 프로토콜을 사용할 수 있습니다. CIDR 주석을 사용하는 클러스터 전체 프록시가 활성화된 경우 출력은 IP 주소가 아닌 서버 이름 또는 FQDN이어야 합니다.
    6
    보안 연결의 경우 secret을 지정하여 인증하는 https 또는 http URL을 지정할 수 있습니다.
    7
    https 접두사의 경우 TLS 통신의 엔드포인트에 필요한 보안 이름을 지정합니다. 시크릿은 openshift-logging 프로젝트에 있어야 하며 해당하는 각 인증서를 가리키는 tls.crt,tls.keyca-bundle.crt 키가 있어야 합니다. 그러지 않으면 httphttps 접두사의 경우 사용자 이름과 암호가 포함된 시크릿을 지정할 수 있습니다. 자세한 내용은 다음 "예: 사용자 이름과 암호가 포함된 시크릿 설정".
    8
    선택 사항: 파이프라인의 이름을 지정합니다.
    9
    파이프라인을 사용하여 전달할 로그 유형 (application, infrastructure, 또는 audit)을 지정합니다.
    10
    이 파이프라인으로 로그를 전달할 때 사용할 출력 이름을 지정합니다.
    11
    선택 사항: Loki의 TenantID 필드 값을 생성할 meta-data 키 필드를 지정합니다. 예를 들어 tenantKey: kubernetes.namespace_name을 설정하면 Kubernetes 네임스페이스의 이름이 Loki의 테넌트 ID 값으로 사용됩니다. 지정할 수 있는 다른 로그 레코드 필드를 보려면 다음 "추가 리소스" 섹션의 "로그 레코드 필드" 링크를 참조하십시오.
    12
    선택 사항: 기본 Loki 레이블을 바꾸려면 meta-data 필드 키 목록을 지정합니다. Loki 레이블 이름은 정규식 [a-zA-Z_:][a-zA-Z0-9_:]*와 일치해야 합니다. 메타 데이터 키의 잘못된 문자는 레이블 이름을 형성하기 위해 _로 대체됩니다. 예를 들어 kubernetes.labels.foo 메타 데이터 키는 Loki 레이블 kubernetes_labels_foo가 됩니다. labelKeys를 설정하지 않으면 기본값은 [log_type, kubernetes.namespace_name, kubernetes.pod_name, kubernetes_host] 입니다. Loki는 허용되는 레이블의 크기와 수를 제한하므로 레이블 세트를 작게 유지합니다. Configuring Loki, limits_config를 참조하십시오. 쿼리 필터를 사용하여 로그 레코드 필드를 기반으로 쿼리할 수 있습니다.
    참고

    Loki는 타임스탬프에 의해 로그 스트림을 올바르게 정렬해야 하므로 labelKeys에는 항상 kubernetes_host 레이블 세트가 포함됩니다. 이렇게 하면 각 스트림이 단일 호스트에서 시작되도록 하여 서로 다른 호스트의 클록 차이로 인해 타임스탬프가 무질서해지는 것을 방지할 수 있습니다.

  2. CR 오브젝트를 생성합니다.

    $ oc create -f <file-name>.yaml
    Copy to Clipboard Toggle word wrap

7.12.1. Loki "주문 부족" 오류 문제 해결

Fluentd가 대량의 메시지 블록을 속도 제한을 초과하는 Loki 로깅 시스템에 전달하는 경우 Loki는 "주문 부족" 오류를 생성합니다. 이 문제를 해결하려면 Loki 서버 구성 파일인 loki.yaml에서 일부 값을 업데이트합니다.

참고

Loki.yaml은 Grafana 호스팅 Loki에서 사용할 수 없습니다. 이는 Grafana 호스팅 Loki 서버에는 적용되지 않습니다.

조건

  • ClusterLogForwarder 사용자 정의 리소스는 로그를 Loki로 전달하도록 구성되어 있습니다.
  • 시스템에서 2MB보다 큰 메시지 블록을 Loki에 보냅니다. 예를 들면 다음과 같습니다.

    "values":[["1630410392689800468","{\"kind\":\"Event\",\"apiVersion\":\
    .......
    ......
    ......
    ......
    \"received_at\":\"2021-08-31T11:46:32.800278+00:00\",\"version\":\"1.7.4 1.6.0\"}},\"@timestamp\":\"2021-08-31T11:46:32.799692+00:00\",\"viaq_index_name\":\"audit-write\",\"viaq_msg_id\":\"MzFjYjJkZjItNjY0MC00YWU4LWIwMTEtNGNmM2E5ZmViMGU4\",\"log_type\":\"audit\"}"]]}]}
    Copy to Clipboard Toggle word wrap
  • oc logs -c fluentd를 입력하면 OpenShift Logging 클러스터의 Fluentd 로그에 다음 메시지가 표시됩니다.

    429 Too Many Requests Ingestion rate limit exceeded (limit: 8388608 bytes/sec) while attempting to ingest '2140' lines totaling '3285284' bytes
    
    429 Too Many Requests Ingestion rate limit exceeded' or '500 Internal Server Error rpc error: code = ResourceExhausted desc = grpc: received message larger than max (5277702 vs. 4194304)'
    Copy to Clipboard Toggle word wrap
  • Loki 서버에서 로그를 열면 다음과 같은 entry out of order 메시지가 표시됩니다.

    ,\nentry with timestamp 2021-08-18 05:58:55.061936 +0000 UTC ignored, reason: 'entry out of order' for stream:
    
    {fluentd_thread=\"flush_thread_0\", log_type=\"audit\"},\nentry with timestamp 2021-08-18 06:01:18.290229 +0000 UTC ignored, reason: 'entry out of order' for stream: {fluentd_thread="flush_thread_0", log_type="audit"}
    Copy to Clipboard Toggle word wrap

절차

  1. Loki 서버의 loki.yaml 구성 파일에서 다음 필드를 여기에 표시된 값으로 업데이트합니다.

    • grpc_server_max_recv_msg_size: 8388608
    • chunk_target_size: 8388608
    • ingestion_rate_mb: 8
    • ingestion_burst_size_mb: 16
  2. Loki .yaml의 변경 사항을 Loki 서버에 적용합니다.

loki.yaml 파일 예

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096
  grpc_server_max_recv_msg_size: 8388608

ingester:
  wal:
    enabled: true
    dir: /tmp/wal
  lifecycler:
    address: 127.0.0.1
    ring:
      kvstore:
        store: inmemory
      replication_factor: 1
    final_sleep: 0s
  chunk_idle_period: 1h       # Any chunk not receiving new logs in this time will be flushed
  chunk_target_size: 8388608
  max_chunk_age: 1h           # All chunks will be flushed when they hit this age, default is 1h
  chunk_retain_period: 30s    # Must be greater than index read cache TTL if using an index cache (Default index read cache TTL is 5m)
  max_transfer_retries: 0     # Chunk transfers disabled

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

storage_config:
  boltdb_shipper:
    active_index_directory: /tmp/loki/boltdb-shipper-active
    cache_location: /tmp/loki/boltdb-shipper-cache
    cache_ttl: 24h         # Can be increased for faster performance over longer query periods, uses more disk space
    shared_store: filesystem
  filesystem:
    directory: /tmp/loki/chunks

compactor:
  working_directory: /tmp/loki/boltdb-shipper-compactor
  shared_store: filesystem

limits_config:
  reject_old_samples: true
  reject_old_samples_max_age: 12h
  ingestion_rate_mb: 8
  ingestion_burst_size_mb: 16

chunk_store_config:
  max_look_back_period: 0s

table_manager:
  retention_deletes_enabled: false
  retention_period: 0s

ruler:
  storage:
    type: local
    local:
      directory: /tmp/loki/rules
  rule_path: /tmp/loki/rules-temp
  alertmanager_url: http://localhost:9093
  ring:
    kvstore:
      store: inmemory
  enable_api: true
Copy to Clipboard Toggle word wrap

맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat