<p>I have a Grafana running on an EC2 instance. I installed my Kubernetes cluster k8s.mydomain.com on AWS using kops. I wanted to monitor this cluster with Grafana. Entering the below URL for Prometheus data source and the admin username and password from <code>kops get secrets kube --type secret -oplaintext</code>  in grafana returned an error.</p>

<p><a href="https://api.k8s.afaquesiddiqui.com/api/v1/namespaces/monitoring/services/prometheus-k8s:9090/proxy/graph#!/role?namespace=default" rel="nofollow noreferrer">https://api.k8s.afaquesiddiqui.com/api/v1/namespaces/monitoring/services/prometheus-k8s:9090/proxy/graph#!/role?namespace=default</a></p>

<p>I also tried the kops add-on for <a href="https://github.com/kubernetes/kops/blob/master/docs/addons.md" rel="nofollow noreferrer">prometheus</a> but I wasn't able to access grafana using the following URL:</p>

<p><a href="https://api.k8s.mydomain.com/api/v1/namespaces/monitoring/services/grafana:3000/proxy/#!/role?namespace=default" rel="nofollow noreferrer">https://api.k8s.mydomain.com/api/v1/namespaces/monitoring/services/grafana:3000/proxy/#!/role?namespace=default</a></p>

<p>Am I doing something wrong? Is there a better way to do this?</p>

Afaque Hussain
<p>The URLs that you specified are proxy endpoints so they are accessed through a proxy that is usually set up on your client with:</p>

<pre><code>kubectl proxy
</code></pre>

<p>I supposed you could access it from the outside if you expose your kube-apiserver to the outside which highly unrecommended.</p>

<p>If you want to access the endpoint from the outside you usually do it through the <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">Kubernetes Service</a> which in your first case is <code>prometheus-k8s</code> on port <code>9090</code> and in the second case is <code>grafana</code> on port <code>3000</code>.  You didn't provide whether the services are exposed through a <a href="https://kubernetes.io/docs/concepts/services-networking/service/#nodeport" rel="nofollow noreferrer"><code>NodePort</code></a> or <a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer"><code>LoadBalancer</code></a> so the endpoint will vary depending on how it's exposed.  You can find out with:</p>

<pre><code>kubectl get svc
</code></pre>
