Collecting historical data of sessions running in mongodb server

Hi Team,

Can someone guide me on how to collect the historical data of sessions that are running in mongodb server ?
For Instance, If I need the queries that are running in a span of 5 min on a particular day, where can I get those details ?

Mongodb Profiling is a good option, but we need to capture each and every query.

Can we save the db.CurrentOp() to a collection in another database ?

Thanks in Advance

Hi Team,

Appreciate If we have any response for the above mentioned problem.


Hello @Rama_Kiran ,

Welcome to the community!! :slight_smile:

If you are using MongoDB enterprise edition then you can refer to auditing in MongoDB.

Else if you are using Atlas cluster M10 or greater, then you can refer to database auditing in Atlas.

From developer perspective, you can add a logging layer in between your application and database which could log the queries being sent to database.


Hello @Tarun_Gaur

Thank you for your response. However, If we are using community version of MongoDB, Is there a way to collect the historical data of sessions that are running?

Thank you
Rama Kiran

Hello @Rama_Kiran,

For community version I would suggest you to go with Developer’s approach and add a logging layer to save session’s data.


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