Working with Monitoring Tools
1. Using db.serverStatus() Command
| Section | Detail |
|---|---|
| connections | current, available, totalCreated |
| opcounters | insert/query/update/delete/getmore/command |
| wiredTiger | Cache, transactions, concurrent ops |
| metrics | Cursor, document, operation metrics |
2. Monitoring with mongostat Utility
mongostat --uri=... 1
| Column | Detail |
|---|---|
| insert/query/update/delete | Per-second op counts |
| dirty / used | WT cache % |
| qrw, arw | Queued/active readers/writers |
3. Monitoring with mongotop Utility
| Column | Detail |
|---|---|
| total / read / write | Time per collection |
| Use | Identify hot collections |
4. Checking Current Operations
db.currentOp({ active:true, secs_running: { $gt: 5 } });
5. Killing Operations
| Method | Detail |
|---|---|
| db.killOp(opid) | Cancel an operation |
| Caution | Cannot kill internal ops |
6. Monitoring Replication Lag
| Method | Detail |
|---|---|
| rs.printSecondaryReplicationInfo() | Per-secondary lag |
| replSetGetStatus | optimeDate vs primary |
7. Checking Lock Statistics
| Source | Detail |
|---|---|
| serverStatus().locks | Acquire counts per resource |
| currentOp lockStats | Per-op wait time |
8. Monitoring Memory Usage
| Metric | Detail |
|---|---|
| mem.resident | RSS (MB) |
| tcmalloc | Allocator stats |
| wiredTiger.cache.bytes | Currently in cache |
9. Checking Connection Metrics
| Metric | Detail |
|---|---|
| current | Active connections |
| available | Remaining slots |
| totalCreated | Lifetime count |
10. Using Free Monitoring
| Aspect | Detail |
|---|---|
| Edition | Community (non-Atlas) |
| Enable | db.enableFreeMonitoring() |
| Provides | 24h cloud dashboard URL |