Docs Menu

Docs HomeMongoDB Manual


On this page

  • Definition
  • Syntax
  • Access Control
  • Examples

New in version 4.4.

Returns a document that contains information about whether the chunks of a sharded collection are balanced (i.e. do not need to be moved) as of the time the command is run or need to be moved because of draining shards, zone violation or imbalance of chunks across shards.


mongosh Method

This page documents a mongosh method. This is not the documentation for database commands or language-specific drivers, such as Node.js.

For the database command, see the balancerCollectionStatus command.

For MongoDB API drivers, refer to the language-specific MongoDB driver documentation.

For the legacy mongo shell documentation, refer to the documentation for the corresponding MongoDB Server release:

mongo shell v4.4

The sh.balancerCollectionStatus() has the following form:

sh.balancerCollectionStatus( <namespace> )

The sh.balancerCollectionStatus() method takes the following parameter:


The namespace of the collection to shard in the form "<database>.<collection>".

When running with access control, the user must have the enableSharding privilege actions on database and/or collection to run the method. That is, a user must have a role that grants the following privilege:

{ resource: { db: <database>, collection: <collection> }, actions: [ "enableSharding" ] }

The built-in clusterManager role provides the appropriate privileges.

To check whether the chunks of a sharded collection test.contacts is currently in balance, connect to a mongos instance and issue the following:


If the chunks for the collection do not need to be moved, the method returns an output similar to the following:

"balancerCompliant" : true,
"ok" : 1,
"operationTime" : Timestamp(1583193238, 1),
"$clusterTime" : {
"clusterTime" : Timestamp(1583193238, 1),
"signature" : {
"keyId" : NumberLong(0)

If the queried namespace is going through chunk defragmentation, the sh.balancerCollectionStatus method returns output similar to the following:

"balancerCompliant": false,
"firstComplianceViolation": "defragmentingChunks",
"details": {
"currentPhase": "moveAndMergeChunks",
"progress": { "remainingChunksToProcess": 1 }


Chunk defragmentation occurs in multiple phases. The progress field only pertains to the current phase.

For the description of the output, see balancerCollectionStatus Output.

←  sh.addTagRange()sh.commitReshardCollection() →
Share Feedback
© 2023 MongoDB, Inc.


  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.