<p>I am new to kubernetes environment, i need to calculate POD based TPS using prometheus. Can any one guide me in this regard.</p>

Shahid Farooq
<p>Assuming that the  <code>http_requests_total</code>  time series all have the labels  <code>job</code>  (fanout by job name) and  <code>instance</code>  (fanout by instance of the job), you might want to sum over the rate of all instances, so you get fewer output time series, but still preserve the  <code>job</code>  dimension:</p>

<pre><code>sum by (job)(rate(http_requests_total{job="pod"}[5m]))
</code></pre>

<p>This sequence:  </p>

<pre><code>rate(http_requests_total{job="pod"}[5m])
</code></pre>

<p>returns only the per-second rate of HTTP requests as measured over the last 5 minutes, per time series in the range vector.</p>

<p><code>rate</code>  should only be used with counters. It is best suited for alerting, and for graphing of slow-moving counters.</p>

<p>Note that when combining  <code>rate()</code>  with an aggregation operator (e.g.  <code>sum()</code>) or a function aggregating over time (any function ending in  <code>_over_time</code>), always take a  <code>rate()</code>  first, then aggregate. Otherwise  <code>rate()</code>  cannot detect counter resets when your target restarts.</p>

<p>If you will be interested in the total of HTTP requests you have seen in  <strong>all</strong>  applications, you could simply write:</p>

<pre><code>sum(http_requests_total)
</code></pre>

<p><strong>EDIT:</strong></p>

<p>After digging in I have noticed that the official <a href="https://prometheus.io/docs/introduction/first_steps/" rel="nofollow noreferrer">Prometheus documentation</a> uses <code>http_requests_total</code> in some examples however this metric does not seem to exist in the current stable version as <a href="http://localhost:9090/metrics" rel="nofollow noreferrer">http://localhost:9090/metrics</a> does not include it. </p>

<p>Take a look: <a href="https://github.com/prometheus/docs/pull/1078" rel="nofollow noreferrer">http_requests_total</a>.
Name of this metrics has been changed from <code>http_requests_total</code> to <code>promhttp_metric_handler_requests_total</code>. Try to change name of this metrics in above examples and it should work.</p>

<p>Please take a look: <a href="https://sysdig.com/blog/prometheus-metrics/" rel="nofollow noreferrer">prometheus-metrics-http-requests</a>, <a href="https://timber.io/blog/promql-for-humans/" rel="nofollow noreferrer">PromQL</a>, <a href="https://www.robustperception.io/rate-then-sum-never-sum-then-rate" rel="nofollow noreferrer">prometheus-way-of-counting</a>.</p>
