본문으로 건너뛰기

Loki

배포 Mode

  • Monolithic
    • 모든 컴포넌트를 하나의 인스턴스에 배포
    • 하루에 20GB 정도의 읽기/쓰기가 있는 환경에서 사용 가능
  • Simple scalable
    • 읽기 컴포넌트들과 쓰기 컴포넌트들로 분리하여 배포
    • 하루에 ~ 10TB 정도의 읽기/쓰기가 있는 환경에서 사용 가능
  • Microservices
    • 모든 컴포넌트를 분리하여 배포, 가장 자유도가 높지만 유지보수도 어려움

컴포넌트

Loki Docs / Architecture

  • Distributor: 클라이언트에서 들어오는 로그를 검증 후 Ingester로 전달
  • Ingester: Distributor로부터 받은 로그를 임시 또는 장기 저장
  • Query Frontend: 쿼리를 조정, 쿼리 대기열 관리 등을 수행
  • Querier: Ingester 또는 장기 저장소에서 로그를 쿼리
Componentmicroservicesinglereadwritebackend
DistributorOO-O-
IngesterOO-O-
Query FrontendOOO--
Query SchedulerOO--O
QuerierOOO--
Index GatewayO---O
CompactorOO--O
RulerOO--O

설치

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update grafana \
&& helm search repo grafana/loki -l | head -n 10
helm pull grafana/loki --version 6.30.1
helm show values grafana/loki --version 6.30.1 > loki-6.30.1.yaml
loki-values.yaml
deploymentMode: SimpleScalable

global:
extraArgs:
- -config.expand-env=true
extraEnvFrom: []

loki:
auth_enabled: false

schemaConfig:
configs:
- # 인덱스 생성 시작일, 스키마가 변경되면 변경이 시작되는 날짜
from: "2024-03-31"
store: tsdb
# chunks가 저장되는 저장소로 기본값으로 store 값을 씁니다. aws(alias s3), azure,
# alibabacloud, bos, cos, swift, filesystem, or a named_store
object_store: s3
schema: v13
index:
prefix: loki_index_
period: 24h

storage:
bucketNames:
chunks: loki
ruler: loki
admin: loki
type: s3
s3:
s3ForcePathStyle: true
endpoint: "http://${BUCKET_HOST}:${BUCKET_PORT}"
region: "${BUCKET_REGION}"
accessKeyId: "${AWS_ACCESS_KEY_ID}"
secretAccessKey: "${AWS_SECRET_ACCESS_KEY}"

storage_config:
tsdb_shipper:
active_index_directory: /var/loki/tsdb-index
cache_location: /var/loki/tsdb-cache
cache_ttl: 168h

ingester:
chunk_encoding: snappy

querier:
max_concurrent: 4

limits_config:
max_entries_limit_per_query: 10000

read:

backend:
persistence:
storageClass: ""

write:
persistence:
storageClass: ""

gateway:
podLabels: {}
경고

read(querier, queryFrontend), gateway는 쿼리되는 로그의 양에 따라 OOMKilled가 발생할 수 있으므로 모니터링을 통해 적절한 값을 설정해야 합니다.

  • loki
    • Loki Docs / Configure
    • storage
    • storage_config
    • ingester
    • querier
      • max_concurrent: 4
        • 성능 개선이 필요하고, 리소스가 충분하다면 늘려볼 수 있습니다.
        • OOM 등 문제가 발생하면 줄여볼 수 있습니다.
    • compactor
    • limits_config
helm template loki grafana/loki \
--version 6.30.1 \
-n loki \
-f loki-values.yaml \
> loki.yaml
helm upgrade loki grafana/loki \
--install \
--history-max 5 \
--version 6.30.1 \
-n loki \
-f loki-values.yaml

Grafana