Logging/Monitoring Architecture

Promtail, Loki, Grafana
Logging and Monitoring Architecture with Fluentd, ElasticSearch, Grafana for Kubernetes.


1. Basic Logging Construction


Node Level Logging for Kubernetes.

1-1) Deployment 생성

apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-log
spec:
  selector:
    matchLabels:
      type: app
      app: app-log
  template:
    metadata:
      labels:
        type: app
        app: app-log
    spec:
      nodeSelector:
        kubernetes.io/hostname: k8s-node1
      containers:
      - name: container
        image: kubetm/app

api 호출

curl <pod-ip>:8080/hostname
curl <pod-ip>:8080/version

1-2) Container Log 확인

kubectl exec로 Container 내부 로그파일 확인

kubectl exec <pod-name> -it -- /bin/sh

kubectl logs로 Stdout 로그 확인

kubectl logs <pod-name>
kubectl logs <pod-name> --tail 10 --follow

Containerd Log 설정 확인

cat /etc/containerd/config.toml


cd /var/log/pods
cd <Namespace>_<pod-name>_<pod-id>
cd container
ls -al

cd /var/log/containers
ls -al

1-4) Event Log 확인

kubectl get events
kubectl get events | grep app-log

1-5) Termination Log 확인

Termination API Call

curl <pod-ip>:8080/termination

Container Status 확인

kubectl describe pods <pod-name>


2. Loki Stack 설치


Loki Stack for Kubernetes.

설치 가이드 바로가기

https://cafe.naver.com/kubeops/30



Referenece


Kubernetes