<p>I have installed kubernetes metrics-server <a href="https://github.com/kubernetes-sigs/metrics-server" rel="nofollow noreferrer">https://github.com/kubernetes-sigs/metrics-server</a> It works fine, I can use &quot;kubectl top pods&quot; &amp; &quot;kubectl top nodes&quot;, Now I want to scrape the metrics to prometheus outside kubernetes cluster to be shown on Grafana, What I have tried are</p>
<ol>
<li>Expose the metrics-server service using NodePort but not working, some https issue appear</li>
<li>Install metrics-server-exporter from <a href="https://github.com/ghouscht/metrics-server-exporter/" rel="nofollow noreferrer">https://github.com/ghouscht/metrics-server-exporter/</a> (this one only scrape few metrics, I cannot see it on grafana) and <a href="https://github.com/grupozap/metrics-server-exporter/" rel="nofollow noreferrer">https://github.com/grupozap/metrics-server-exporter/</a> (this one is not an http application, so I cannot expose as a NodePort Service)</li>
</ol>
<p>What should I do?</p>

Aditia Rahman
<p>Try these out and let me know.</p>
<p>1.First you should run kube-state-metrics which collects all kubernetes metrics .</p>
<p>2.Using pod annotations on the kube-state-metrics , expose metrics like</p>
<pre><code>prometheus.io/scrape: 'true'
prometheus.io/port: 'port'
prometheus.io/path: '/metrics'
prometheus.io/scheme: 'http'
</code></pre>
<p>This should expose your metrics from the pod level . To check this you can exec in to the pod and do a curl request on the port followed by the path</p>
<p>3.Now run a prometheus agent which can scrape metrics from this port and send it to the backend db server</p>
<p>4.Configure prometheus ds in your grafana agent and it should be done</p>
