<p>How does one add a where clause in PromQL?</p>
<p>I'm trying to construct a query that displays when an application running in Kubernetes has been up for more than one minute but I want to filter by namespace.</p>
<p>This is what my query looks like at the moment</p>
<pre><code>100 * (count(up == 1) BY (job, namespace, service) ) &gt; 1
</code></pre>
<p>This works fine but it gives me additional information that I don't need.</p>
<pre><code>{job=&quot;prometheus-grafana&quot;, namespace=&quot;monitor&quot;, service=&quot;prometheus-grafana&quot;}
{job=&quot;jenkins&quot;, namespace=&quot;jenkins&quot;, service=&quot;jenkins&quot;}
{job=&quot;kube-state-metrics&quot;, namespace=&quot;monitor&quot;, service=&quot;prometheus-kube-state-metrics&quot;}
{job=&quot;node-exporter&quot;, namespace=&quot;monitor&quot;, service=&quot;prometheus-prometheus-node-exporter&quot;}
{job=&quot;kubelet&quot;, namespace=&quot;kube-system&quot;, service=&quot;prometheus-kube-prometheus-kubelet&quot;}
{job=&quot;apiserver&quot;, namespace=&quot;default&quot;, service=&quot;kubernetes&quot;}
</code></pre>
<p>What I'm trying to accomplish is to get results for only the <code>jenkins</code> and <code>default</code> namespace.</p>
<pre><code>{job=&quot;apiserver&quot;, namespace=&quot;default&quot;, service=&quot;kubernetes&quot;}
{job=&quot;jenkins&quot;, namespace=&quot;jenkins&quot;, service=&quot;jenkins&quot;}
</code></pre>
<p>I've tried doing</p>
<pre><code>100 * (count(up == 1) BY (job, namespace, service) ) &gt; 1 and ON {namespace=&quot;jenkins&quot;}
</code></pre>
<p>But I get an <code>invalid parameter &quot;query&quot;: 1:65: parse error: unexpected &quot;{&quot; in grouping opts, expected &quot;(&quot;</code> error.</p>

<p>You would have to filter the metric &quot;up&quot; by the labels you want (namespaces) in your case it should look something like this:</p>
<pre><code>100 * count(up{namespace=~&quot;default|jenkins&quot;} == 1) &gt; 1
</code></pre>
