Grafana HTTP Error Bad Gateway and Templating init failed errors

Use helm installed Prometheus and Grafana on minikube at local.

$ helm install stable/prometheus
$ helm install stable/grafana

Prometheus server, alertmanager grafana can run after set port-forward:

$ export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
$ kubectl --namespace default port-forward $POD_NAME 9090

$ export POD_NAME=$(kubectl get pods --namespace default -l "app=prometheus,component=alertmanager" -o jsonpath="{.items[0].metadata.name}")
$ kubectl --namespace default port-forward $POD_NAME 9093

$ export POD_NAME=$(kubectl get pods --namespace default -l "app=excited-crocodile-grafana,component=grafana" -o jsonpath="{.items[0].metadata.name}")
$ kubectl --namespace default port-forward $POD_NAME 3000


Add Data Source from grafana, got HTTP Error Bad Gateway error:

Import dashboard 315 from:

Kubernetes cluster monitoring (via Prometheus) | Grafana Labs

Then check Kubernetes cluster monitoring (via Prometheus), got Templating init failed error:

Why?

Hi,

I think you need to use the internal ip of prometheus when setting up data source. The port forward you setting up is only for your computer.

Marcus

Thank you. I changed Access from proxy to direct, it works.

Okay.

Please note that problems may arise related to direct access, for example if you’re planning on using the alerting feature in Grafana.

Marcus

Good. So it seems that the internal ip of prometheus is the best way.

Yes. Last time I used kubernetes with helm, grafana and prometheus I could see the hostname in kubernetes somewhere placed as a label which I could then reference in Grafana to connect to prometheus. Suggest you look this up in helm community.

Marcus

Okay, thank you very much for your answer and your help!

Hi,
I use docker installed Prometheus and Grafana at local.
prometheus localhost:9090 => OK
Grafana community.grafana.com => OK
node_exporter localhost:9100 => OK
When I want to add a prometheus database in grafana:
localhost: 9090 => KO
docker adress 172.17… => KO
can you help me please ?
thanks