<p>I'm still getting to grips with PromQL. I wrote this query in an attempt to detect the number of kubernetes pods that existed in the last 24 hours within a given namespace.</p>
<p><strong>My process here was:</strong></p>
<ul>
<li>Get the metric filtered to the relevant name-spaces (any airflow ones).</li>
<li>Get that metric over 24 hours.
<ul>
<li>Each pod will just have lots of duplicates of the same creation time here.</li>
</ul>
</li>
<li>Use <code>increase()</code> to get the range vectors for each pod back into instant vectors.  The value will always be 0 as the creation time  does not increase.</li>
<li>Now that we have 1 value per pod, use <code>count()</code> to see how many existed in that time frame.</li>
</ul>
<pre><code>count(increase(kube_pod_created{namespace=~&quot;.*-airflow&quot;}[1d]))
</code></pre>
<p>Can anyone that knows prometheus well tell me if this logic follows?  Since it isn't a normal database/etc I'm having trouble working out how to validate this query.  It &quot;looks&quot; like it probably does the right thing when expanded out to a day though.</p>

John Humphreys
<p>I'd recommend substituting <code>increase()</code> with <code>count_over_time()</code>, since <code>increase</code> may miss short-living pods with lifetime smaller than 2x scrape interval. The following query should return the total number of pods seen during the last 24 hours:</p>
<pre><code>count(count_over_time(kube_pod_created{namespace=~&quot;.*airflow&quot;}[24h]))
</code></pre>
