# Elastic-apm Java agent the unable to get msearch quries and aggregate & find mongo quries

**URL:** <https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795>\
**Category:** APM\
**Tags:** java\
**Created:** [September 9, 2025, 11:47am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795 "2025-09-09T11:47:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![uttamkrpanda](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uttamkrpanda](https://discuss.elastic.co/u/uttamkrpanda)\
**Post date:** [September 9, 2025, 11:47am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/1 "2025-09-09T11:47:54Z")

</div>

**Kibana version** : 8.17

**Elasticsearch version** : 8.17.0

**APM Server version** : 1.55.0

**APM Agent language and version** : apm-javaagent , 1.55.0

**Browser version** :

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**:

**Fresh install or upgraded from other version? Upgraded**

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

I am not getting the elasticsearch msearch queries getting displayed in span details and also the aggregate and find mongo queries are not getting displayed .

I am using below environment variables . Could you please suggest is there anything else i am missing here to display the queries ?

ELASTIC\_APM\_ELASTICSEARCH\_CAPTURE\_BODY\_URLS: \*\_count, \*\_sql, \*\_eql/search, \*\_async\_search, \*\_search/template, \*\_msearch/template, \*\_search, \*\_msearch  
ELASTIC\_APM\_LONG\_FIELD\_MAX\_LENGTH: 200000  
ELASTIC\_APM\_TRANSACTION\_MAX\_SPANS: 2000

**Steps to reproduce** :

1. installed latest elastic-apm java agent 1.55.0
2. Perform some msearch and mongodb activities

---

<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:** [September 9, 2025, 12:25pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/2 "2025-09-09T12:25:36Z")

</div>

It’s not clear from your description what you are getting vs what you’re expecting. Are you getting these details for other types of ES and MONGODB queries, and this is specific to these subset? Or are you getting nothing related to ES and MONGODB?

Have you checked the [supported tech](https://www.elastic.co/docs/reference/apm/agents/java/supported-technologies) to see if the versions you are using are supported? Have you turned on [log\_level](https://www.elastic.co/docs/reference/apm/agents/java/config-logging) to debug to check the transactions and spans are being emitted for the requests you are expecting them to be emitted for?

For MONGDB I note there is also a [mongodb\_capture\_statement\_commands](https://www.elastic.co/docs/reference/apm/agents/java/config-datastore#config-mongodb-capture-statement-commands) option that might help

---

<div class="post-metadata">

**Author:** ![uttamkrpanda](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uttamkrpanda](https://discuss.elastic.co/u/uttamkrpanda)\
**Post date:** [September 9, 2025, 12:46pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/3 "2025-09-09T12:46:30Z")

</div>

Hi @Jack_Shirazi ,

I am getting related to ES and MongoDB . But in some of subsets its not getting captured the msearch queries .

---

<div class="post-metadata">

**Author:** ![uttamkrpanda](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uttamkrpanda](https://discuss.elastic.co/u/uttamkrpanda)\
**Post date:** [September 9, 2025, 1:15pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/4 "2025-09-09T13:15:36Z")

</div>

As per document [Datastore configuration options | APM Java agent](https://www.elastic.co/docs/reference/apm/agents/java/config-datastore#config-mongodb-capture-statement-commands)  
i have updated the ELASTIC\_APM\_ELASTICSEARCH\_CAPTURE\_BODY\_URLS: \*\_count, \*\_sql, \*\_eql/search, \*\_async\_search, \*\_search/template, \*\_msearch/template, \*\_search, \*\_msearch

which has the msearch , however it’s not capturing the msearch queires .

---

<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:** [September 9, 2025, 1:34pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/5 "2025-09-09T13:34:51Z")

</div>

But you ARE getting other queries? Are you sure you are making msearch queries?

---

<div class="post-metadata">

**Author:** ![uttamkrpanda](https://avatars.discourse-cdn.com/v4/letter/u/3da27b/32.png) [@uttamkrpanda](https://discuss.elastic.co/u/uttamkrpanda)\
**Post date:** [September 9, 2025, 1:51pm UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/6 "2025-09-09T13:51:24Z")

</div>

![Screenshot 2025-09-09 at 7.12.29 PM](https://us1.discourse-cdn.com/elastic/original/3X/6/c/6c7b498073829de3dc8523da8eeecafb3ef0bdf2.png)

Yeah i am making msearch only . i think sometimes i am not getting other queries too . Is there any default setting available which i am missing ?

---

<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:** [September 10, 2025, 10:53am UTC](https://discuss.elastic.co/t/elastic-apm-java-agent-the-unable-to-get-msearch-quries-and-aggregate-find-mongo-quries/381795/7 "2025-09-10T10:53:26Z")

</div>

There is no option that I can think of. If you are sometimes not getting details and sometimes you are, that’s very strange. Look for dropped spans in the logs (agent, apm server) and dropped span statistics. You can see exactly what the agent is sending by switching log\_level to trace, but it’s very verbose
