<p>I am trying to create a 'PrometheusRule' inside my cluster with some alert rules using <code>promql</code> expressions. However, I want these resources to be used and configurable for different services inside my same cluster. All I want to do is have Variable values inside my &quot;expr&quot; field, something like this:</p>
<pre><code>expr: sum( nginx_ingress_controller_requests{status=~&quot;5.+&quot;} ) &gt; VARIABLE_VALUE
</code></pre>
<p>Instead of:</p>
<pre><code>expr: sum( nginx_ingress_controller_requests{status=~&quot;5.+&quot;} ) &gt; 50
</code></pre>
<p>This is the <code>PromethuesRule</code> I am trying to make:</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: blablaname
  namespace: blablans
spec:
  groups:
  - name: {{ include &quot;blabla.fullname&quot; . }}-cache
    rules:
    - alert: TOOMANY5XXX
      annotations:
        description: too many 5XXs
        summary: blablabla
      expr: sum( nginx_ingress_controller_requests{status=~&quot;5.+&quot;} ) &gt; VARIABLE_VALUE
      for: 5m
      labels:
        severity: critical
</code></pre>
<p>PS: I am using Helm charts as my package manager and would like the Variable to be present in my <code>Values.yaml</code> file</p>

RyanDotnet
<p>If you are using helm then use simple variable assignment:</p>
<pre><code>expr: sum( nginx_ingress_controller_requests{status=~&quot;5.+&quot;} ) &gt; {{ .Values.VariableValue }}
</code></pre>
