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.