10

Loki를 이용한 손쉬운 Kubernetes Logging

 2 years ago
source link: https://dev.to/airoasis/lokireul-iyonghan-sonswiun-kubernetes-logging-1iho
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Loki는 Prometheus 와 같은 철학으로 탄생한 cloud native infra를 위한 logging 서비스이다. 개인적으로 EFK 도 사용해보고 Datadog의 logging 도 사용해 봤지만 Loki가 제일 마음에 든다. (Datadog 이나 New Relic 과 같은 서비스를 사용하지 않는다면 Loki를 사용하여 Logging을 하면 가벼운 Kubernetes logging 서비스를 구축 가능한다.)

Loki 설치

$ helm repo add grafana https://grafana.github.io/helm-charts
$ helm repo update
$ helm upgrade --install loki grafana/loki-stack --create-namespace --namespace=loki --set grafana.enabled=true,grafana.service.type=LoadBalancer,loki.config.table_manager.retention_deletes_enabled=true,loki.config.table_manager.retention_period=336h,loki.persistence.enabled=true,loki.persistence.size=5Gi

Enter fullscreen mode

Exit fullscreen mode

  • loki namespace를 생성
  • 상용에 사용할 수 있도록 데이터를 persist 한다.
  • Grafana를 외부로 노출한다
  • 최근 2주동안의 로그를 저장하고 오래된 순서대로 삭제

Loki 확인

접속 주소를 확인

$ kubectl get svc -n loki

Enter fullscreen mode

Exit fullscreen mode

Grafana의 admin password를 확인한다.

$ kubectl get secret --namespace loki loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo

Enter fullscreen mode

Exit fullscreen mode

login ID는 admin 이고 password는 위에서 얻은 값이다.

결국 Grafana를 통해 서비스 되고 Explore tab 에서 Loki를 선택하여 log를 확인할 수 있다.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK