This version of the documentation is archived and no longer supported.

$currentOp (aggregation)


New in version 3.6.


Returns a stream of documents containing information on active and/or dormant operations for the MongoDB deployment. To run $currentOp, use the db.aggregate() helper on the admin database.

$currentOp offers a better alternative to the currentOp command and the db.currentOp method. The latter two commands are limited to returning all operations in a single document, which must not exceed the maximum 16MB BSON size. Since $currentOp pipelines return a cursor, they are not subject to these limitations.

$currentOp also enables you to perform arbitrary transformations of the results as the documents pass through the pipeline.

$currentOp takes an options document as its operand.

{ $currentOp: { allUsers: <boolean>, idleConnections: <boolean> } }

Specify an empty document to use the default values.


Option Description

Boolean. If set to false, $currentOp will only report operations belonging to the user who ran the command. If set to true, $currentOp will report operations belonging to all users.


The inprog privilege is necessary to run $currentOp with { allUsers : true }.

Defaults to false.


Boolean. If set to false, $currentOp will only report active operations. If set to true, all operations including idle connections will be returned.

Defaults to false.


  • $currentOp must be the first stage in the pipeline.
  • Pipelines that start with $currentOp can only be run on the admin database.
  • On a standalone or replica set with authentication enabled, the inprog privilege is required to run $currentOp if the allUsers parameter is set to true.
  • On a sharded cluster, the inprog privilege is required to run all $currentOp pipelines.


The following example runs the $currentOp operation in the first stage and filters the results of that operation in the second stage.

use admin
db.aggregate( [
   { $currentOp : { allUsers: true, idleConnections: true } },
   { $match : { shard: "shard01" } }
] )