# Nodejs Agent not instrumenting MongoDB calls

**URL:** <https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417>\
**Category:** APM\
**Created:** [February 19, 2018, 8:35am UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417 "2018-02-19T08:35:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kishoreacesurf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishoreacesurf/32/27890_2.png) [@kishoreacesurf](https://discuss.elastic.co/u/kishoreacesurf)\
**Post date:** [February 19, 2018, 8:35am UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/1 "2018-02-19T08:35:17Z")

</div>

Nodejs Express Agent is not instrumenting mongoDB calls

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [February 19, 2018, 2:16pm UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/2 "2018-02-19T14:16:46Z")

</div>

We should instrument all MongoDB queries, but there can be some things can mean we are not able to.

If you don't mind answering a few questions, then we'll take a look:

- Which Node.js version are you using?
- Which version of the Node.js agent are you using?
- Which MongoDB module (and its version) are you using?

Best,  
Thomas

---

<div class="post-metadata">

**Author:** ![kishoreacesurf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishoreacesurf/32/27890_2.png) [@kishoreacesurf](https://discuss.elastic.co/u/kishoreacesurf)\
**Post date:** [February 20, 2018, 6:19am UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/3 "2018-02-20T06:19:23Z")

</div>

Which Node.js version are you using?  
6.11.2  
Which version of the Node.js agent are you using?  
1.0.3  
Which MongoDB module (and its version) are you using?  
"mongodb": "^2.2.11",  
"mongoose": "~4.4.3",

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [February 20, 2018, 8:14am UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/4 "2018-02-20T08:14:36Z")

</div>

That _should_ be instrumented. It sounds like you're requiring mongoose before requiring and starting the APM agent. That's required in order for instrumentation to work. Check that you have added the call to `start()` at the very top of your applications main file (e.g. if you run `node server.js`, then `server.js` is your main file)

---

<div class="post-metadata">

**Author:** ![Richard\_Bell](https://avatars.discourse-cdn.com/v4/letter/r/838e76/32.png) [@Richard\_Bell](https://discuss.elastic.co/u/Richard_Bell)\
**Post date:** [February 21, 2018, 11:46am UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/5 "2018-02-21T11:46:51Z")

</div>

Hi, I am not able to find out what Elastic's recommended way to connect to MongoDB to my ElasicSearch cloud, this discussion seems to be assuming some basic knowledge, could you please point me in the direction of that basic knowledge.

So far I am assuming I use **Beats** embedded in a **NODE.JS** service to send to send **MongoDB** data to **Logstash** for ingesting into **Cloud Elasticseach** where I can then interrogate using Kabina.

Would be grateful for any guidance.

Richard

---

<div class="post-metadata">

**Author:** ![kishoreacesurf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kishoreacesurf/32/27890_2.png) [@kishoreacesurf](https://discuss.elastic.co/u/kishoreacesurf)\
**Post date:** [February 21, 2018, 1:16pm UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/6 "2018-02-21T13:16:49Z")

</div>

Thanks. I moved it above routes and it started working. Thank you

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [February 21, 2018, 3:02pm UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/7 "2018-02-21T15:02:31Z")

</div>

Hi Richard

It sounds like your question is regarding Kibana. Could I get you to post it as a new Topic at [https://discuss.elastic.co/c/kibana](https://discuss.elastic.co/c/kibana) ?

/thomas

---

<div class="post-metadata">

**Author:** ![wa7son](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wa7son/32/21259_2.png) [@wa7son](https://discuss.elastic.co/u/wa7son)\
**Post date:** [February 21, 2018, 3:03pm UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/8 "2018-02-21T15:03:16Z")

</div>

Glad to hear that it helped Jaya 😃

---

<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:** [March 14, 2018, 11:03am UTC](https://discuss.elastic.co/t/nodejs-agent-not-instrumenting-mongodb-calls/120417/9 "2018-03-14T11:03:34Z")

</div>

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