Search code examples
kubernetesgrafanagrafana-loki

Unable to add Grafana Loki datasource in Kubernetes


I am following the following grafana documentation on loki. I am unable to properly connect to my k8s clusters loki logs after installing loki, promtail, and grafana via helm charts. When I enter the http: url in Add datasources within the Grafana GUI and proceed to save & test, grafana is unable to connect to loki.

My helm commands are:

helm upgrade --install --namespace=monitoring promtail grafana/promtail --set "loki.serviceName=loki"
helm upgrade --install loki --namespace=monitoring grafana/loki-distributed
helm install --namespace=monitoring loki-grafana grafana/grafana

Now I mainly am having trouble with this step and the syntax and how to debug the process: "using the URL http://helm-installation-name-gateway.namespace.svc.cluster.local/ for Loki (with and replaced by the installation and namespace, respectively, of your deployment)."

I have tried all of the following URLs with no luck, any guidance would be very appreciated!

http://loki-grafana.monitoring.svc.cluster.local:3100

Unable to fetch labels from Loki (Failed to call resource), please check the server logs for more details


Solution

  • I figured it out.

    helm repo add loki https://grafana.github.io/loki/charts
    helm repo update
    kubectl create namespace monitoring
    helm upgrade --install loki --namespace=monitoring grafana/loki-stack
    helm upgrade --install grafana --namespace monitoring grafana/grafana
    kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
    kubectl port-forward --namespace loki service/grafana 3000:80
    

    Then when you log into grafana use http://loki:3100 for the datasource url

    The guide I found is here: https://medium.com/codex/setup-grafana-loki-on-local-k8s-cluster-minikube-90450e9896a8

    I just skipped the minikube and ingress stuff