Logging with Grafana and Loki
Install the Prometheus stack:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm upgrade --install prometheus prometheus-community/kube-prometheus-stack --namespace monitor --create-namespace
Install Loki:
helm repo add loki https://grafana.github.io/loki/charts
helm upgrade --install loki --namespace=monitoring grafana/loki-stack --create-namespace
Setup Data Sources in Grafana
- 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
 
- Port-forward grafana dashboard 
- Add a data source by navigating to http://localhost:3000/datasources or click "Data Sources" under the ⚙️ icon from left menu.  
- Click on "Add Data Sources" and select "Loki" from the list.  
- Enter the loki endpoint in the - URLfield as- http://loki.monitoring:3100or to the corresponding- <name>.<namespace>:<port>value according to your deployment, and click on "Save & test". 
- 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.  
