Ultimate Guide: Centralized Logging for AWS Graviton EKS with Loki & Fluentd!

Here’s how to enable centralized logging for your AWS Graviton-based EKS Cluster using Loki & Fluentd πŸš€


πŸ”Ή Step 1: Install Loki, Fluentd & Promtail via Helm

helm repo add grafana https://grafana.github.io/helm-charts
helm repo update

# Install Loki (log aggregation)
helm install loki grafana/loki-stack --namespace monitoring --set fluent-bit.enabled=true --set promtail.enabled=true --create-namespace

Verify Loki installation:

kubectl get pods -n monitoring

πŸ”Ή Step 2: Expose Loki for External Access

Create LoadBalancer service (loki-service.yaml):

apiVersion: v1
kind: Service
metadata:
  name: loki
  namespace: monitoring
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "alb"
spec:
  selector:
    app: loki
  ports:
    - protocol: TCP
      port: 3100
      targetPort: 3100
  type: LoadBalancer

Apply the service:

kubectl apply -f loki-service.yaml

Check the external URL:

kubectl get svc -n monitoring

Look for EXTERNAL-IP under the loki service.


πŸ”Ή Step 3: Configure Loki as a Data Source in Grafana

  1. Go to Grafana β†’ Settings β†’ Data Sources
  2. Add a new data source β†’ Select Loki
  3. Enter URL: http://loki.monitoring.svc:3100
  4. Save & Test

πŸ”Ή Step 4: Configure Fluentd to Collect Logs

Create Fluentd config (fluentd-configmap.yaml):

apiVersion: v1
kind: ConfigMap
metadata:
  name: fluentd-config
  namespace: monitoring
data:
  fluent.conf: |
    <source>
      @type tail
      path /var/log/containers/*.log
      pos_file /var/log/fluentd.pos
      tag kubernetes.*
      format json
    </source>

    <match kubernetes.**>
      @type loki
      url http://loki.monitoring.svc:3100
      flush_interval 5s
    </match>

Apply Fluentd configuration:

kubectl apply -f fluentd-configmap.yaml

πŸ”Ή Step 5: Deploy Fluentd DaemonSet

Create (fluentd-daemonset.yaml):

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: monitoring
spec:
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      serviceAccount: fluentd
      containers:
        - name: fluentd
          image: fluent/fluentd-kubernetes-daemonset:v1-debian
          volumeMounts:
            - name: varlog
              mountPath: /var/log
      volumes:
        - name: varlog
          hostPath:
            path: /var/log

Apply Fluentd:

kubectl apply -f fluentd-daemonset.yaml

βœ… Conclusion

🎯 Your Graviton EKS cluster now has:

  • πŸ”₯ Real-time centralized logging
  • πŸ“Š Loki & Fluentd log aggregation
  • πŸ“ˆ Logs visible in Grafana

Would you like to set up alerts for log anomalies using Prometheus Alertmanager? πŸš€

About Anant 443 Articles
Senior technical writer

1 Trackbacks & Pingbacks

  1. Complete Monitoring & Logging for AWS Graviton EKS: Prometheus, Grafana & More! – KTCHost

Comments are closed.