<p>First off to avoid x-y questions: I'd like to achieve HPA based on loadbalancer metrics coming from a specific ingress.</p>

<p>I have a HPA based on a <code>request_count</code> external metric coming from stackdriver.
I want to match the label in the following way, in order to get only the requests coming to a specific ingress.</p>

<pre><code>...HPAmanifest...
- type: External
    external:
      metricName: loadbalancing.googleapis.com|https|request_count
      metricSelector:
        matchLabels:
          resource.labels.target_proxy_name: k8s-tps-appname-appname-ingress--64658eaf6b9dce83
      targetAverageValue: 50
</code></pre>

<p>The problem is that by doing that, I neglect HTTP traffic (which does happen and it's beyond our power to prevent that), which means that my app won't scale if there's a huge number of HTTP requests.</p>

<p>If I am not mistaken, expressing something similar makes the HPA catch metrics containing BOTH labels, which means that no metric will be matched at all. (note, the only difference between them is the "s" after "tp", which distinguishes traffic coming from http/s)</p>

<pre><code>...HPAmanifest...
- type: External
    external:
      metricName: loadbalancing.googleapis.com|https|request_count
      metricSelector:
        matchLabels:
          resource.labels.target_proxy_name: k8s-tps-appname-appname-ingress--64658eaf6b9dce83
          resource.labels.target_proxy_name: k8s-tp-appname-appname-ingress--64658eaf6b9dce83
      targetAverageValue: 50
</code></pre>

<p>Is it possible to use a "or" match, (or a regex alternatively) in order to achieve HPA based on loadbalancer metrics coming from a specific ingress? </p>

<p>NB: I do not filter on label <code>url-map</code> because on the stackdriver web UI I see that the graphs are not matching for some reason (I'll give better looks in the meanwhile)</p>

<p>Thanks</p>

linuxbandit
<p>I am not sure exactly what went wrong back then, though the answer is exactly what I have ruled out (as per my original question): in order to filter the requests arriving to a specific ingress, one must filter on label <code>url-map</code></p>

<p>So my working HPA is now having in the matchLabels:</p>

<pre><code>...
      metricSelector:
        matchLabels:
          resource.labels.url_map_name: k8s-tps-appname-appname-ingress--345afb364
</code></pre>

<p>and it doesn't cause problems of using an "OR" selector as per my question here. Notice that the ingress annotation is <code>url-map</code> with hyphens, which is "transformed" in <code>url_map_name</code> (with underscores); this happens with all others annotations too (in my original question, <code>target-proxy</code> as ingress annotation becomes <code>target_proxy_name</code> in the label</p>

<p>For future readers: you can't <code>OR</code> the conditions in a matchLabel currently (1.15) in k8s.</p>
