<p>I have a use case where we need monitor the threads inside our pods, by using &quot;kubectl top&quot; i am able to monitor CPU, MEMORY.I am new to kubernetes and need to monitor the threads inside our pods.</p>
<pre><code>NAME                   CPU(cores)   CPU%      MEMORY(bytes)   MEMORY%
ip-XXX.ec2.internal    222m         11%       3237Mi          41%
ip-YYY.ec2.internal    91m          9%        2217Mi          60%
</code></pre>

ik009
<p>You need to instrument your code using some standard library depending on the language the application is written and then you can expose the metrics at <code>/metrics</code> endpoint which can be scraped by prometheus and shown in a Grafana dashboard.</p>
<p>If it's a JVM based app then <a href="https://micrometer.io" rel="nofollow noreferrer">micrometer</a> is easy to use and exposes some metrics by default.</p>
<p>All other major languages has <a href="https://prometheus.io/docs/instrumenting/clientlibs/" rel="nofollow noreferrer">prometheus client library</a> which can used to instrument code and expose metrics.</p>
