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
Gelli

Hi Team,

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

Thanks

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.

Regards,
Tarun

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.

Tarun

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