Navigation

Determine Status of Data Lake Queries

Beta

The Atlas Data Lake is available as a Beta feature. The product and the corresponding documentation may change at any time during the Beta stage. For support, see Atlas Support.

You can determine the status of a running query using $currentOp (aggregation). To run $currentOp, use the db.aggregate helper. $currentOp must be run against the admin database.

Syntax

db.aggregate([{$currentOp: {} }])

Output

$currentOp returns documents with the following fields:

FieldTypeDescription
$currentOp.typestringType of operation. Value is always op.
$currentOp.clientstringIP address (or hostname) and the ephemeral port of the client connection where the operation originates.
$currentOp.clientMetadataDocument
Additional client information such as the client:
  • Application name
  • Driver name and version number
  • Operating System name, type, architecture, and version number
$currentOp.activebooleanSpecifies whether the operation has started. Value is true if the operation has started or completed and false if the operation is idle.
$currentOp.currentOpTimeISODateStart time of the operation.
$currentOp.nsstringNamespace that the opration targets. A namespace consists of the database name and the collection name concatenated with a dot (.); that is, "<database>.<collection>".
$currentOp.commandDocumentA document containing the command object associated with this operation.
$currentOp.msgstringA message that describes the status and progress of the operation.
$currentOp.progressDocumentA document that contains the amount of work done for the operation.
$currentOp.progress.workDoneintegerA number that increases as documents move through the pipeline, indicating that progress has been made toward the completion of the query. This number is not a percentage and cannot be used to estimate how much work remains.

Examples

For the example below, suppose the following query is being run on the airbnb collection in the sample database described in the Getting Started tutorial.

db.airbnb.find( { "address.market" : "Porto", "review_scores.review_scores_rating": {$gt: 79}})

The following example returns information on the previous query being run on the airbnb collection in the sample database:

db.aggregate([{$currentOp: {} }])

$currentOp returns the following documents. The workDone field shows that 770 documents had been processed at the time that $currentOp was run.

{
      "type" : "op",
      "client" : "73.231.201.205:62351",
      "clientMetadata" : {
             "application" : {
                     "name" : "MongoDB Shell"
             },
             "driver" : {
                     "name" : "MongoDB Internal Client",
                     "version" : "4.2.0"
             },
             "os" : {
                     "type" : "Darwin",
                     "name" : "Mac OS X",
                     "architecture" : "x86_64",
                     "version" : "18.7.0"
             }
      },
      "active" : true,
      "currentOpTime" : ISODate("2020-03-26T12:51:43.291Z"),
      "ns" : "sample.airbnb",
      "command" : {
             "find" : "airbnb",
             "filter" : {
                     "address.market" : "Porto",
                     "review_scores.review_scores_rating" : {
                             "$gt" : 79
                     }
             },
             "lsid" : {
                     "id" : UUID("2211f8ac-56b2-4ba4-bb0c-2e5dd5b7cc21")
             },
             "$db" : "sample"
      },
      "msg" : "work done: 770",
      "progress" : {
             "workDone" : 770
      }
}
{
      "type" : "op",
      "client" : "73.231.201.205:62353",
      "clientMetadata" : {
             "application" : {
                     "name" : "MongoDB Shell"
             },
             "driver" : {
                     "name" : "MongoDB Internal Client",
                     "version" : "4.2.0"
             },
             "os" : {
                     "type" : "Darwin",
                     "name" : "Mac OS X",
                     "architecture" : "x86_64",
                     "version" : "18.7.0"
             }
      },
      "active" : true,
      "currentOpTime" : ISODate("2020-03-26T12:51:47.380Z"),
      "ns" : "admin.$cmd.aggregate",
      "command" : {
             "aggregate" : 1,
             "pipeline" : [
                     {
                             "$currentOp" : {

                             }
                     }
             ],
             "cursor" : {

             },
             "lsid" : {
                     "id" : UUID("045ea383-65d7-4e88-a989-37b7a8da23bc")
             },
             "$db" : "admin"
      },
      "msg" : "work done: 0",
      "progress" : {
             "workDone" : 0
      }
}