Skip to main content

Loki


배포 Mode


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

컴포넌트

https://grafana.com/docs/loki/latest/fundamentals/architecture/components/

  • Distributor: 클라이언트에서 들어오는 로그를 검증 후 Ingester로 전달
  • Ingester: Distributor로부터 받은 로그를 임시 또는 장기 저장
  • Query Frontend: 쿼리를 조정, 쿼리 대기열 관리 등을 수행
  • Querier: Ingester 또는 장기 저장소에서 로그를 쿼리
https://grafana.com/docs/loki/latest/getting-started/

설치

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update grafana \
&& helm search repo grafana/loki-distributed -l | head -n 10
helm pull grafana/loki-distributed --version 0.78.4
helm show values loki-distributed-0.78.4.tgz > loki-distributed-0.78.4.yaml
loki-distributed-values.yaml
fullnameOverride: "loki"

loki:
# -- Check https://grafana.com/docs/loki/latest/configuration/#schema_config
# for more info on how to configure schemas
schemaConfig:
configs:
- # 인덱스 생성 시작일, 스키마가 변경되면 변경이 시작되는 날짜
from: 2024-03-31
store: boltdb-shipper
# chunks가 저장되는 저장소로 기본값으로 store 값을 씁니다. aws(alias s3), azure,
# alibabacloud, bos, cos, swift, filesystem, or a named_store
object_store: s3
schema: v12
index:
prefix: loki_index_
period: 24h

# -- Check https://grafana.com/docs/loki/latest/configuration/#storage_config
# for more info on how to configure storages
storageConfig:
# https://grafana.com/docs/loki/latest/configure/#aws_storage_config
aws:
# s3: s3://<region>/<bucket>
s3forcepathstyle: true
endpoint: "http://${BUCKET_HOST}:${BUCKET_PORT}"
region: "${BUCKET_REGION}"
bucketnames: "${BUCKET_NAME}"
access_key_id: "${AWS_ACCESS_KEY_ID}"
secret_access_key: "${AWS_SECRET_ACCESS_KEY}"

boltdb_shipper:
shared_store: s3
active_index_directory: /var/loki/index
cache_location: /var/loki/cache
cache_ttl: 168h

# -- Structured loki configuration, takes precedence over `loki.config`, `loki.schemaConfig`, `loki.storageConfig`
structuredConfig:
limits_config:
max_entries_limit_per_query: 10000

ingester:
extraArgs:
- -config.expand-env=true
extraEnvFrom:
- secretRef:
name: loki-bucket
- configMapRef:
name: loki-bucket
resources: {}

distributor:
extraArgs:
- -config.expand-env=true
extraEnvFrom:
- secretRef:
name: loki-bucket
- configMapRef:
name: loki-bucket
resources: {}

querier:
extraArgs:
- -config.expand-env=true
extraEnvFrom:
- secretRef:
name: loki-bucket
- configMapRef:
name: loki-bucket
resources: {}

queryFrontend:
extraArgs:
- -config.expand-env=true
extraEnvFrom:
- secretRef:
name: loki-bucket
- configMapRef:
name: loki-bucket
resources: {}

gateway:
podLabels: {}
resources: {}

compactor:
enabled: false

ruler:
enabled: false
warning

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

helm template loki loki-distributed-0.78.4.tgz \
-n monitoring \
-f loki-distributed-values.yaml \
> loki-distributed.yaml
helm upgrade loki loki-distributed-0.78.4.tgz \
--install \
--history-max 5 \
-n monitoring \
-f loki-distributed-values.yaml

삭제

helm uninstall -n monitoring loki

Grafana