<p>I have configured the ambassador in my local and applied plugin filter, following is the filter config</p>
<pre><code>apiVersion: getambassador.io/v1beta1
kind: Filter
metadata:
  name: &quot;x-dc-filter&quot;
spec:
  Plugin:
    name: &quot;x-dc-plugin&quot;

---
apiVersion: getambassador.io/v1beta1
kind: FilterPolicy
metadata:
  name: &quot;x-dc-filter-policy&quot;
spec:
  rules:
  - host: &quot;*&quot;
    path: &quot;*&quot;
    filters:               
    - name: &quot;x-dc-filter&quot;  
</code></pre>
<p>Have bundled the plugin .so file as part of ambassador docker image and verified the plugin is available in /etc/ambassador-plugins path in pod. On starting the ambassador got following logs from pod</p>
<pre><code>Calling Metriton
2020-11-27 06:11:28 diagd 1.9.1 [P75TThreadPoolExecutor-0_1] INFO: B155B245-326B-4CA6-8ECF-A9034B478E5E: 127.0.0.1 &quot;GET /ambassador/v0/diag/&quot; 22ms 200 success
2020/11/27 06:11:35 aggregator: watch hook stderr: 2020-11-27 06:11:35 watch-hook WARNING: &lt;Filter ambassador.default.1&gt;: no handler for Filter, just saving
2020/11/27 06:11:35 aggregator: watch hook stderr: 2020-11-27 06:11:35 watch-hook WARNING: &lt;FilterPolicy ambassador.default.2&gt;: no handler for FilterPolicy, just saving
2020/11/27 06:11:35 aggregator: watch hook stderr:
2020/11/27 06:11:35 kubernetes:secret|default|*|*: signaling shutdown
2020/11/27 06:11:35 kubernetes:secret|default|*|*: exited
2020/11/27 06:11:35 kubernetes:service|default|*|*: signaling shutdown
2020/11/27 06:11:35 kubernetes:service|default|*|*: exited
2020-11-27 06:11:35 diagd 1.9.1 [P75TAEW] WARNING: &lt;Filter ambassador.default.1&gt;: no handler for Filter, just saving
2020-11-27 06:11:35 diagd 1.9.1 [P75TAEW] WARNING: &lt;FilterPolicy ambassador.default.2&gt;: no handler for FilterPolicy, just saving
2020-11-27 06:11:36 diagd 1.9.1 [P75TAEW] INFO: configuration updated (complete) from snapshot 3 (S8 L1 G8 C3)
time=&quot;2020-11-27 06:11:36&quot; level=warning msg=&quot;license_secret_watch: empty decoded license data&quot; func=github.com/datawire/apro/cmd/amb-sidecar/runner.runE.func4 file=&quot;github.com/datawire/apro/cmd/amb-sidecar/runner/main.go:300&quot; MAIN=license_secret_watch
time=&quot;2020-11-27 06:11:36&quot; level=warning msg=&quot;license_secret_watch: empty decoded license data&quot; func=github.com/datawire/apro/cmd/amb-sidecar/runner.runE.func4 file=&quot;github.com/datawire/apro/cmd/amb-sidecar/runner/main.go:300&quot; MAIN=license_secret_watch
2020/11/27 06:11:36 aggregator: watch hook stderr: 2020-11-27 06:11:36 watch-hook WARNING: &lt;Filter ambassador.default.1&gt;: no handler for Filter, just saving
2020/11/27 06:11:36 aggregator: watch hook stderr: 2020-11-27 06:11:36 watch-hook WARNING: &lt;FilterPolicy ambassador.default.2&gt;: no handler for FilterPolicy, just saving
2020/11/27 06:11:36 aggregator: watch hook stderr:
2020-11-27 06:11:37 diagd 1.9.1 [P75TAEW] WARNING: &lt;Filter ambassador.default.1&gt;: no handler for Filter, just saving
2020-11-27 06:11:37 diagd 1.9.1 [P75TAEW] WARNING: &lt;FilterPolicy ambassador.default.2&gt;: no handler for FilterPolicy, just saving
2020-11-27 06:11:37 diagd 1.9.1 [P75TAEW] INFO: configuration updated (complete) from snapshot 4 (S8 L1 G8 C3)
time=&quot;2020-11-27 06:11:37&quot; level=warning msg=&quot;license_secret_watch: empty decoded license data&quot; func=github.com/datawire/apro/cmd/amb-sidecar/runner.runE.func4 file=&quot;github.com/datawire/apro/cmd/amb-sidecar/runner/main.go:300&quot; MAIN=license_secret_watch
time=&quot;2020-11-27 06:11:37&quot; level=warning msg=&quot;license_secret_watch: empty decoded license data&quot; func=github.com/datawire/apro/cmd/amb-sidecar/runner.runE.func4 file=&quot;github.com/datawire/apro/cmd/amb-sidecar/runner/main.go:300&quot; MAIN=license_secret_watch
2020/11/27 06:11:38 aggregator: watch hook stderr: 2020-11-27 06:11:38 watch-hook WARNING: &lt;Filter ambassador.default.1&gt;: no handler for Filter, just saving
2020/11/27 06:11:38 aggregator: watch hook stderr: 2020-11-27 06:11:38 watch-hook WARNING: &lt;FilterPolicy ambassador.default.2&gt;: no handler for FilterPolicy, just saving
2020/11/27 06:11:38 aggregator: watch hook stderr:
2020-11-27 06:11:38 diagd 1.9.1 [P75TAEW] WARNING: &lt;Filter ambassador.default.1&gt;: no handler for Filter, just saving
2020-11-27 06:11:38 diagd 1.9.1 [P75TAEW] WARNING: &lt;FilterPolicy ambassador.default.2&gt;: no handler for FilterPolicy, just saving
2020-11-27 06:11:38 diagd 1.9.1 [P75TAEW] INFO: configuration updated (complete) from snapshot 5 (S8 L1 G8 C3)
time=&quot;2020-11-27 06:11:38&quot; level=warning msg=&quot;license_secret_watch: empty decoded license data&quot; func=github.com/datawire/apro/cmd/amb-sidecar/runner.runE.func4 file=&quot;github.com/datawire/apro/cmd/amb-sidecar/runner/main.go:300&quot; MAIN=license_secret_watch
time=&quot;2020-11-27 06:11:38&quot; level=warning msg=&quot;license_secret_watch: empty decoded license data&quot; func=github.com/datawire/apro/cmd/amb-sidecar/runner.runE.func4 file=&quot;github.com/datawire/apro/cmd/amb-sidecar/runner/main.go:300&quot; MAIN=license_secret_watch
2020-11-27 06:12:27 diagd 1.9.1 [P75TThreadPoolExecutor-0_0] INFO: 44A5439F-C2E4-46C8-9D57-F5F4B6654E72: 127.0.0.1 &quot;GET /ambassador/v0/diag/&quot; 22ms 200 success
2020-11-27 06:13:27 diagd 1.9.1 [P75TThreadPoolExecutor-0_0] INFO: 15FD78F9-B331-4D57-B838-FEB5CB066C82: 127.0.0.1 &quot;GET /ambassador/v0/diag/&quot; 16ms 200 success
2020-11-27 06:13:38 diagd 1.9.1 [P75TAEW] INFO: TIMER reconfiguration: 5, 0.121/0.260/0.406
</code></pre>

sreekesh.s
<p>Abassador request mapping is working in following way</p>
<ol>
<li>Any request to ambassador gateway will first check for any matches available for request in mapping,</li>
<li>If any mapping matches and then it invokes the filter if filter policy rule matches with the request.</li>
<li>The filter plugin applies the logic and update the request</li>
<li>After filter logic the request get mapped with any of the mapping and route to the actual service</li>
</ol>
<p>So In order to avoid the above problem added following mapping</p>
<pre><code>annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v1
      kind:  Mapping
      name:  dc_1_mapping
      prefix: &quot;/getHostName&quot;
      rewrite: &quot;&quot;
      headers:
        X-Dc: odd
      service: testservice1:8081
      ---
        apiVersion: ambassador/v1
        kind:  Mapping
        name:  dc_2_mapping
        prefix: &quot;/getHostName&quot;
        headers:
          X-Dc: even
        service: testservice2:8082
        rewrite: &quot;&quot;
      ---
      apiVersion: ambassador/v1
      kind:  Mapping
      name:  dc_3_mapping
      prefix: &quot;/getHostName&quot;
      service: testservice3:8083
      rewrite: &quot;&quot;
</code></pre>
<p>Note: The X-dc-plugin filter mentioned in question just updates the request header X-Dc wit odd or even based on the id in query param.</p>
<p>Example flow:</p>
<p>Here if I send a request http://localhost/getHostName?id=2  this will be matching the last mapping and then route request to filter. The filter updates the header with even as id in query param is 2. Then ambassador again tries to match the request with the mapping above with header even and route the request to testService2:8082</p>
