dataiotech Labs
Scripts Library/mongodb/#98
Script #98
mongodb
Maintenanceread-onlyMin Version: 4.2

MongoDB Index Build Progress

Shows the percentage and duration of in-flight index builds. Helps estimate when an index build on a large collection will finish.

#index-build#progress#currentOp
mongodb · javascript
db.getSiblingDB("admin").aggregate([
  { $currentOp: { allUsers: true } },
  { $match: { $or: [ { "command.createIndexes": { $exists: true } }, { msg: /Index Build/ } ] } },
  { $project: { opid: 1, ns: 1, secs_running: 1, msg: 1, progress: 1, "command.indexes": 1 } }
]);
Operational Notes & Remediation Guidance

Verify in a staging environment prior to running in production. This is a read-only diagnostic query; it does not acquire exclusive locks.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 4.2).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.

Engineering Triad: Related Runbooks & Incident Response

Which production incidents and emergency drills execute this script as a diagnosis step?

Runbook Library (63)
Proactive Maintenance & Health Check: This script is not tied to an active incident alert; it is intended for scheduled maintenance, capacity planning, and routine DBA audits.