[Kubernetes] Install Loki(v3.1.1) Distributed Using Helm Chart

Helm 설치 및 설명 참고 {: .prompt-info }

Install the Loki Distributed Helm charts #

1helm repo add grafana https://grafana.github.io/helm-charts
2helm repo update
3helm install loki-distributed grafana/loki-distributed --namespace [NAMESPACE NAME] --version [VERSION]

Loki Distributed - Helm 설치 참고

Customize Default Configuration #

Loki Configurations #

Loki 설정 값 문서

  • https://grafana.com/docs/loki/latest/configuration/ {: .prompt-info }

  • Grafana Loki 모범 사례

    • 레이블은 Loki에서 Log를 검색할 때 필터링이 되는 기준이 되는데 여기선 정적 레이블을 가급적이면 사용하라고 가이드하고 있다.
      • 레이블은 클라이언트에서 설정한 다음에 Loki에게 Push하면 된다.
    • chunk_target_size를 사용하라고 한다.
      • 기본 1.5MB 사이즈로 모든 청크 크기를 채우도록 하는게 좋다고 한다.
    • chunk_encoding은 기본값이 gzip인데 snappy를 권고한다고 한다.
      • 이게 훨씬 더 압축을 푸는데도 빠르고 쿼리 속도도 더 빠르다고 한다.
    • max_chunk_age는 2h을 권고한다고 한다.
    • chunk_idle_period은 1h ~ 2h을 권고한다고 한다.
    • RF(Replication factor)를 항상 설정할 것을 권고한다.
      • 데이티의 손실 가능성을 완화하기 위해 Ingester의 복제 요소를 일반적으로 3개로 설정할 것을 권고하고 있다.
      • 복제 요소가 데이터 손실을 방지하는 유일한 요소는 아니며, 주요 목적은 롤아웃 및 재시작 중에 쓰기가 중단되지 않도록 하는 것이다.

참고

참고

Loki에 대한 모니터링 참고

analytics false #

1analytics:
2  reporting_enabled: false

Compactor와 Table Manager #

  • Grafana Loki의 로그 보존(Retention)은 Compactor 혹은 Table Manager에 의해 수행된다.

  • 현재 Table Manager를 통한 Retention은 TTL을 통해 달성되며 boltdb-shipper, chunk/index store 모두 작동한다.

  • Compactor를 통한 Retention은 boltdb-shipper 저장소에서만 지원된다.

  • 만약 Compactor로 Retention을 적용한다면 Table Manager는 필요로 하지 않게 될 수 있다.

  • Compactor 설정 예시

    1compactor:
    2  retention_delete_delay: 2h
    3  delete_request_store: s3
    4  working_directory: "/var/loki/compactor"
    5  retention_enabled: true
    6  retention_delete_worker_count: 150
    7  apply_retention_interval: 1h
    8  compaction_interval: 5m
  • Compactor의 Retention은 limits_config에 설정해주면 된다.

    Retention 설정 참고

storage #

 1schema_config:
 2  configs:
 3    - from: "2024-06-19"
 4      index:
 5        period: 24h
 6        prefix: tsdb_index_
 7      object_store: s3
 8      schema: v13
 9      store: tsdb
10
11storage_config:
12  aws:
13    s3: http://access_key:secret_key@endpoint:port
14    bucketnames: loki-logs
15    s3forcepathstyle: true
16  tsdb_shipper:
17    active_index_directory: /var/loki/tsdb-index
18    cache_location: /var/loki/tsdb-cache
19    index_gateway_client:
20      # only applicable if using microservices where index-gateways are independently deployed.
21      # This example is using kubernetes-style naming.
22      server_address: dns:///index-gateway.<namespace>.svc.cluster.local:9095

minio 설치 참고 {: .prompt-info }

Install Customize Default Configuration #

1helm install [RELEASE NAME] [Chart.yaml 경로] -f [YAML 파일 또는 URL에 값 지정 (여러 개를 지정가능)] -n [NAMESPACE NAME]
1helm install loki-distributed grafana/loki-distributed -f override-values.yaml -n [NAMESPACE NAME]

Uninstall the Chart #

1helm uninstall [RELEASE NAME] -n [NAMESPACE NAME]
Advertisement