# Filter transactions on basis of request header or MDC

**URL:** <https://discuss.elastic.co/t/filter-transactions-on-basis-of-request-header-or-mdc/355842>\
**Category:** APM\
**Tags:** java\
**Created:** [March 20, 2024, 6:13pm UTC](https://discuss.elastic.co/t/filter-transactions-on-basis-of-request-header-or-mdc/355842 "2024-03-20T18:13:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanmayaeron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanmayaeron/32/125662_2.png) [@tanmayaeron](https://discuss.elastic.co/u/tanmayaeron)\
**Post date:** [March 20, 2024, 6:13pm UTC](https://discuss.elastic.co/t/filter-transactions-on-basis-of-request-header-or-mdc/355842/1 "2024-03-20T18:13:01Z")

</div>

I have a usecase where I would like to segregate my requests on the basis of a value present in a particular header, let's say 'X'. X would be set only to true/false. I would like transaction count, latency, errors all segregated. Is it possible in Elastic APM Java agent?

I read about Filters but couldn't understand how I can use it in my case.

Or is it possible to do it by attaching two elastic APM Java agents somehow?

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [March 22, 2024, 2:55pm UTC](https://discuss.elastic.co/t/filter-transactions-on-basis-of-request-header-or-mdc/355842/2 "2024-03-22T14:55:55Z")

</div>

You can't attach 2 Elastic APM agents to one JVM. When you say requests and headers, I presume you mean http requests and headers. We don't have any mechanism to configure the Java agent to do what you want. You can possibly do it yourself using the [public APIs](https://www.elastic.co/guide/en/apm/agent/java/current/apis.html).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 19, 2024, 2:56pm UTC](https://discuss.elastic.co/t/filter-transactions-on-basis-of-request-header-or-mdc/355842/3 "2024-04-19T14:56:40Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
