
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
- Go to Grafana β Settings β Data Sources
- Add a new data source β Select Loki
- Enter URL:
http://loki.monitoring.svc:3100
- 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? π