Skip to main content

Logging with Grafana and Loki

Install the Prometheus stack:

helm repo add prometheus-community
helm upgrade --install prometheus prometheus-community/kube-prometheus-stack --namespace monitor --create-namespace

Install Loki:

helm repo add loki
helm upgrade --install loki --namespace=monitoring grafana/loki-stack --create-namespace

Setup Data Sources in Grafana

  1. Open the Grafana Dashboard:

    • Port-forward grafana dashboard kubectl port-forward -n monitor service/prometheus-grafana 3000:80
    • Get Grafana credentials kubectl get secrets -n monitor prometheus-grafana -o jsonpath='{.data.admin-password}' | base64 -D
    • Navigate to http://localhost:3000
  2. Add a data source by navigating to http://localhost:3000/datasources or click "Data Sources" under the ⚙️ icon from left menu.

  3. Click on "Add Data Sources" and select "Loki" from the list.

  4. Enter the loki endpoint in the URL field as http://loki.monitoring:3100 or to the corresponding <name>.<namespace>:<port> value according to your deployment, and click on "Save & test".

  5. Next click on "Explore" or navigate to http://localhost:3000/explore and select "Loki" from the dropdown menu. Select the desired Labels and Click on "Run query". Your logs should now start appearing.