DEV Community

Hisyam Johan
Hisyam Johan

Posted on • Edited on

Monitor k8s with Loki, Prometheus and Grafana

Bismillah...

We will learn how to monitor Kubernetes using Loki, Prometheus, and Grafana using existing helm packages.

I found two helm packages which are very useful.

First, let's install the helm package for Prometheus:

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install monitoring-stack prometheus-community/kube-prometheus-stack -n monitoring
Enter fullscreen mode Exit fullscreen mode

Next, let's install the helm package for Loki:

helm upgrade --install loki grafana/loki-stack --set fluent-bit.enabled=true,promtail.enabled=false -n monitoring
Enter fullscreen mode Exit fullscreen mode

To access Grafana locally, run the following command:

kubectl port-forward svc/monitoring-stack-grafana 8080:80 -n monitoring
Enter fullscreen mode Exit fullscreen mode

You can now access Grafana by opening localhost:8080 in your browser. Login with the following credentials:

  • Username: admin
  • Password: prom-operator

Next, let's configure Loki as a datasource in Grafana. Follow these steps:

  1. Go to the Grafana dashboard.
  2. Click on "Configuration" in the side menu.
  3. Click on "Data Sources".
  4. Click on "Add data source".
  5. Set the following configurations:

That's it! You have successfully set up monitoring for Kubernetes using Loki, Prometheus, and Grafana.

Enjoy monitoring your Kubernetes cluster!

Sources:

Top comments (0)