mdbkit 0.7.0__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mdbkit-0.7.0/mdbkit.egg-info → mdbkit-0.8.0}/PKG-INFO +321 -121
- mdbkit-0.7.0/PKG-INFO → mdbkit-0.8.0/README.md +308 -144
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/__init__.py +1 -1
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/analysis.py +76 -1
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/cli.py +144 -40
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/filtering.py +4 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/ftdc.py +122 -11
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/host.py +49 -14
- mdbkit-0.8.0/mdbkit/indexusage.py +319 -0
- mdbkit-0.8.0/mdbkit/lab.py +883 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/render.py +97 -11
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/scripts.py +28 -5
- mdbkit-0.8.0/mdbkit/sharding.py +402 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/triage.py +427 -95
- mdbkit-0.7.0/README.md → mdbkit-0.8.0/mdbkit.egg-info/PKG-INFO +344 -117
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit.egg-info/SOURCES.txt +7 -1
- {mdbkit-0.7.0 → mdbkit-0.8.0}/pyproject.toml +17 -4
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_ftdc.py +1 -1
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_host.py +1 -1
- mdbkit-0.8.0/tests/test_indexes.py +185 -0
- mdbkit-0.8.0/tests/test_real_failures.py +181 -0
- mdbkit-0.8.0/tests/test_sharded.py +187 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_triage.py +2 -2
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_v060_hardening.py +82 -0
- mdbkit-0.8.0/tests/test_v080.py +151 -0
- mdbkit-0.7.0/mdbkit/lab.py +0 -542
- {mdbkit-0.7.0 → mdbkit-0.8.0}/LICENSE +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/advisor.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/audit.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/compare.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/demo.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/explain.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/oslog.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/parser.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/rebuild.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/report.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/serverstatus.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit/shelljson.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit.egg-info/dependency_links.txt +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit.egg-info/entry_points.txt +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit.egg-info/requires.txt +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/mdbkit.egg-info/top_level.txt +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/setup.cfg +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_demo_lab.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_explain.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_mdbkit.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_oslog_serverstatus.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_real_servers.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_rebuild_report.py +0 -0
- {mdbkit-0.7.0 → mdbkit-0.8.0}/tests/test_render_e2e.py +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mdbkit
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary: Offline toolkit for MongoDB 4.4 to 9.0
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: Offline toolkit for MongoDB 4.4 to 9.0 logs and diagnostics: slow-query shapes, index advice and index usage, incident triage, sharded clusters, multi-instance hosts, startup configuration audit, FTDC decoding. A spiritual successor to mtools' log tools.
|
|
5
5
|
Author: Saqib Ameen Subhan
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/saqibameen86/mdbkit
|
|
@@ -9,13 +9,22 @@ Project-URL: Repository, https://github.com/saqibameen86/mdbkit
|
|
|
9
9
|
Project-URL: Documentation, https://github.com/saqibameen86/mdbkit#readme
|
|
10
10
|
Project-URL: Issues, https://github.com/saqibameen86/mdbkit/issues
|
|
11
11
|
Project-URL: Changelog, https://github.com/saqibameen86/mdbkit/releases
|
|
12
|
-
Keywords: mongodb,mongodb-logs,logv2,mtools,mloginfo,mongod,slow-query,slow-query-log,log-analysis,log-parser,index-advisor,dba,sre,devops,ftdc,diagnostic-data,explain-plan,query-performance,database-performance,replica-set,wiredtiger,troubleshooting,incident-response
|
|
13
|
-
Classifier: Development Status ::
|
|
12
|
+
Keywords: mongodb,mongodb-logs,logv2,mtools,mloginfo,mongod,slow-query,slow-query-log,log-analysis,log-parser,index-advisor,dba,sre,devops,ftdc,diagnostic-data,explain-plan,query-performance,database-performance,replica-set,wiredtiger,troubleshooting,incident-response,sharding,mongos,sharded-cluster,chunk-migration,index-usage
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
14
|
Classifier: Environment :: Console
|
|
15
15
|
Classifier: Intended Audience :: System Administrators
|
|
16
16
|
Classifier: Intended Audience :: Developers
|
|
17
17
|
Classifier: License :: OSI Approved :: MIT License
|
|
18
18
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
|
+
Classifier: Operating System :: OS Independent
|
|
19
28
|
Classifier: Topic :: Database
|
|
20
29
|
Classifier: Topic :: System :: Systems Administration
|
|
21
30
|
Requires-Python: >=3.8
|
|
@@ -32,12 +41,13 @@ Dynamic: license-file
|
|
|
32
41
|
[](https://pypi.org/project/mdbkit/)
|
|
33
42
|
[](LICENSE)
|
|
34
43
|
|
|
35
|
-
**An offline toolkit for MongoDB
|
|
36
|
-
deterministic index advice,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
(
|
|
44
|
+
**An offline toolkit for MongoDB logs and diagnostics** — slow-query
|
|
45
|
+
analysis, deterministic index advice, unused and redundant indexes, incident
|
|
46
|
+
triage, sharded clusters, hosts running many mongods, a startup
|
|
47
|
+
configuration audit, and diagnostic-data (FTDC) decoding. For MongoDB 4.4
|
|
48
|
+
through 9.0, from the terminal, without connecting to anything.
|
|
49
|
+
**[Tested against real MongoDB 9.0.2, 8.3.11, 8.0.32, 7.0.43 and 6.0.29](#compatibility)**
|
|
50
|
+
— replica sets, standalones and sharded clusters (October 2026).
|
|
41
51
|
|
|
42
52
|
A spiritual successor to mtools' log tools, which never learned to read the
|
|
43
53
|
JSON log format introduced in 4.4.
|
|
@@ -267,40 +277,47 @@ updates — upgrades are always explicit.
|
|
|
267
277
|
## Compatibility
|
|
268
278
|
|
|
269
279
|
**Tested against (October 2026):** MongoDB **9.0.2**, **8.3.11**, **8.0.32**
|
|
270
|
-
(LTS)
|
|
271
|
-
|
|
272
|
-
|
|
280
|
+
(LTS), **7.0.43** (LTS) and **6.0.29**, the newest release in each series at
|
|
281
|
+
the time: replica sets and standalones on all five, and sharded clusters
|
|
282
|
+
(mongos, shards and config servers) on 6.0, 7.0, 8.0 and 9.0. mdbkit reads the structured JSON log format, so anything
|
|
283
|
+
from **4.4** onwards works; 4.2 and earlier wrote plain text logs and are not
|
|
284
|
+
supported.
|
|
273
285
|
|
|
274
286
|
| MongoDB | What mdbkit uses from it |
|
|
275
287
|
|---|---|
|
|
276
288
|
| 4.4 – 7.0 | Everything except the 8.x-only fields below |
|
|
277
|
-
| 8.0 | `workingMillis` (time executing, as distinct from waiting), `queues.execution.totalTimeQueuedMicros` (ticket queue time), `queryShapeHash` (usable with `setQuerySettings`), `planCacheShapeHash`, the 8.0 transparent-huge-page guidance |
|
|
289
|
+
| 8.0 | `workingMillis` (time executing, as distinct from waiting), `queues.execution.totalTimeQueuedMicros` (ticket queue time), `queryShapeHash` (usable with `setQuerySettings`), `planCacheShapeHash`, the 8.0 transparent-huge-page guidance, and FTDC's new layout (sharded processes group metrics by role; WiredTiger checkpoint and eviction statistics were renamed) |
|
|
278
290
|
| 8.1+ | `<stage>Spills` / `<stage>SpilledBytes` (disk spills per stage) |
|
|
279
291
|
| 8.3+ | "Slow in-progress query" lines (id 1794200, component `SLOWPROG`), logged by default for operations still running after 5 s (`--defaultSlowInProgMS`), and `peakTrackedMemBytes` |
|
|
280
292
|
| 9.0 | Same log fields as 8.3. Adds a few fields mdbkit does not use yet (`delinquencyInfo`, `queues.ingress`) |
|
|
281
293
|
|
|
282
294
|
When a field is missing because the log predates it, that part of the output
|
|
283
|
-
is left out. It is never guessed.
|
|
284
|
-
concurrency tickets
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
**How it was tested.** Official MongoDB builds of each version were run
|
|
288
|
-
`mdbkit lab`
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
295
|
+
is left out. It is never guessed. Where MongoDB moved a metric between
|
|
296
|
+
versions (concurrency tickets, checkpoint times, eviction), mdbkit reads both
|
|
297
|
+
the old and the new location.
|
|
298
|
+
|
|
299
|
+
**How it was tested.** Official MongoDB builds of each version were run
|
|
300
|
+
with `mdbkit lab` as a three-node replica set, a standalone and (6.0, 7.0,
|
|
301
|
+
8.0 and 9.0) a sharded cluster with a config server, two shards and a
|
|
302
|
+
mongos. Then each one was broken on purpose, in the ways mdbkit is meant to
|
|
303
|
+
spot:
|
|
304
|
+
|
|
305
|
+
* unindexed queries, sorts that spill to disk, writes blocked behind
|
|
306
|
+
`fsyncLock` and long-running operations;
|
|
307
|
+
* a clean restart, and a primary killed with `kill -9` (the crash, the
|
|
308
|
+
failover and the recovery);
|
|
309
|
+
* a stepdown, and a connection storm of 300 connections at once;
|
|
310
|
+
* flow control, with both secondaries frozen by `fsyncLock` while the
|
|
311
|
+
primary took writes;
|
|
312
|
+
* cache pressure from a working set four times the cache, and a checkpoint
|
|
313
|
+
that ran for over a minute (the process frozen mid-checkpoint);
|
|
314
|
+
* chunk migrations (one failing on purpose), the balancer moving data on its
|
|
315
|
+
own, and a shard killed while queries ran.
|
|
316
|
+
|
|
317
|
+
Every mdbkit command was run on the resulting logs, `diagnostic.data`,
|
|
318
|
+
serverStatus, explain, `getLog` and `$indexStats` output, and compared with
|
|
319
|
+
what the servers did. Trimmed copies of that output are in
|
|
320
|
+
[`tests/fixtures/real/`](tests/fixtures/real/) and run with every test.
|
|
304
321
|
|
|
305
322
|
If mdbkit misreads a line from your deployment, please
|
|
306
323
|
[open an issue](../../issues) with the line (redact as you like).
|
|
@@ -357,12 +374,15 @@ mdbkit triage mongod.log --window 0 # the whole file
|
|
|
357
374
|
mdbkit triage mongod.log --report incident.html # something to attach to a ticket
|
|
358
375
|
```
|
|
359
376
|
|
|
360
|
-
|
|
361
|
-
error clusters, slow-query peaks, startup
|
|
362
|
-
waiting rather than working (8.0+),
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
377
|
+
Crashes and restarts, elections, connection storms, flow control, hot
|
|
378
|
+
collections, index builds, error clusters, slow-query peaks, startup
|
|
379
|
+
misconfiguration, time spent waiting rather than working (8.0+),
|
|
380
|
+
still-running operations (8.3+), and on sharded clusters scatter-gather
|
|
381
|
+
queries, chunk migrations and unreachable shards — plus disk, memory, CPU,
|
|
382
|
+
cache pressure and checkpoints from FTDC when run on the database host.
|
|
383
|
+
Every finding ends with the next command to run. A shutdown followed by the
|
|
384
|
+
server listening again is reported as a restart (WARN); a start with no
|
|
385
|
+
clean shutdown before it, as a crash (CRIT).
|
|
366
386
|
|
|
367
387
|
### 4. Did my change actually help?
|
|
368
388
|
|
|
@@ -452,7 +472,7 @@ last 1440 minutes of each log | 7.8 GiB RAM (this machine)
|
|
|
452
472
|
[CRIT] Cache sizes vs RAM: WiredTiger caches add up to 11.8 GiB, 150% of 7.8 GiB RAM (this machine).
|
|
453
473
|
[CRIT] Instances that crashed: 1 instance(s) started after an unclean stop (crash, kill -9 or OOM kill).
|
|
454
474
|
- vm:29021: 1 unclean start(s)
|
|
455
|
-
[WARN] Default cache size on a shared host: 3 of 8 instances run with the default WiredTiger cache (cacheSizeGB not set). [...]
|
|
475
|
+
[WARN] Default cache size on a shared host: 3 of 8 mongod instances run with the default WiredTiger cache (cacheSizeGB not set). [...]
|
|
456
476
|
|
|
457
477
|
instance set version role cache starts crashes slow ops slow time waiting worst first issue
|
|
458
478
|
-------- ---- ------- ---------- ------- ------ ------- -------- --------- ------- ----- --------------------------
|
|
@@ -468,6 +488,60 @@ the default WiredTiger cache, which assumes the machine is its alone; the
|
|
|
468
488
|
caches add up to several times the RAM and the OOM killer picks off
|
|
469
489
|
instances. (Output above is from a real 8-instance test host.)
|
|
470
490
|
|
|
491
|
+
### 8. Is my sharded cluster sending queries to every shard?
|
|
492
|
+
|
|
493
|
+
```bash
|
|
494
|
+
mdbkit queries /var/log/mongodb/mongos.log # how each query was routed
|
|
495
|
+
mdbkit triage /var/log/mongodb/mongos.log # scatter-gather, unreachable shards
|
|
496
|
+
mdbkit triage /var/log/mongodb/shard1.log # chunk migrations and why they failed
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
namespace op count cumMs mean max shards to all shard wait shape
|
|
501
|
+
shop.orders find 50 520ms 10ms 28ms 2 50/50 97% {createdAt:gt, status:eq} sort:{createdAt:-1}
|
|
502
|
+
shop.orders aggregate 20 291ms 14ms 20ms 2 20/20 90% {status:eq}
|
|
503
|
+
shop.orders find 80 19ms 0ms 3ms 1 0/80 21% {customerId:eq}
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
The router's log shows which query shapes went to every shard (usually no
|
|
507
|
+
shard key in the filter) and which went to one. The shards' logs show chunk
|
|
508
|
+
migrations, how much they moved and why any failed; the config server's
|
|
509
|
+
shows balancer errors. Plans live on the shards, so run `queries` and
|
|
510
|
+
`advise` on a shard log for index advice. (Output from a real 8.0 cluster,
|
|
511
|
+
sharded on `customerId`.)
|
|
512
|
+
|
|
513
|
+
### 9. Which indexes are not earning their keep?
|
|
514
|
+
|
|
515
|
+
```bash
|
|
516
|
+
mdbkit export-script indexes > export_indexes.js
|
|
517
|
+
mongosh --quiet "mongodb://your_db_host:27017/" --eval "$(cat export_indexes.js)" > indexes.json
|
|
518
|
+
mdbkit indexes indexes.json
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
```
|
|
522
|
+
exported from: a mongos (usage from each shard's primary)
|
|
523
|
+
|
|
524
|
+
Unused since the counters started (1)
|
|
525
|
+
shop.orders customerId_1_status_1 { customerId: 1, status: 1 } — 0 use(s)
|
|
526
|
+
no recorded use since the counters started
|
|
527
|
+
test safely: db.getSiblingDB("shop").getCollection("orders").hideIndex("customerId_1_status_1")
|
|
528
|
+
|
|
529
|
+
Redundant: a prefix of another index (1)
|
|
530
|
+
shop.orders status_1 { status: 1 } — 20 use(s)
|
|
531
|
+
its key is a prefix of status_1_createdAt_-1 { status: 1, createdAt: -1 }, which can serve the same queries
|
|
532
|
+
test safely: db.getSiblingDB("shop").getCollection("orders").hideIndex("status_1")
|
|
533
|
+
|
|
534
|
+
Unused, but not a candidate (1)
|
|
535
|
+
shop.orders createdAt_1 { createdAt: 1 } — 0 use(s)
|
|
536
|
+
unused for queries, but it is a TTL index: the TTL monitor uses it, which the counters do not show
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Every index costs write time, memory and disk. This lists the ones with no
|
|
540
|
+
recorded use and the ones another index already covers, and explains the
|
|
541
|
+
ones it deliberately leaves alone (unique, TTL, hidden, the shard key's
|
|
542
|
+
index). It never says "drop": `hideIndex` is the reversible test. (Output
|
|
543
|
+
from a real 8.0 cluster, exported through mongos.)
|
|
544
|
+
|
|
471
545
|
---
|
|
472
546
|
|
|
473
547
|
## Running it on a schedule
|
|
@@ -542,6 +616,8 @@ mdbkit lab start # 3-node replica set on 127.0.0.1:28110-2811
|
|
|
542
616
|
mdbkit lab seed # 50k documents + a deliberately mixed workload
|
|
543
617
|
mdbkit queries $(mdbkit lab logs | head -1)
|
|
544
618
|
mdbkit lab destroy --yes # remove it entirely
|
|
619
|
+
|
|
620
|
+
mdbkit lab start --shards 2 # or a sharded cluster: config server, 2 shards, mongos
|
|
545
621
|
```
|
|
546
622
|
|
|
547
623
|
It binds to localhost only, uses ports far from 27017 so it can never be
|
|
@@ -574,8 +650,11 @@ cat mongod.log | mdbkit queries - # stdin
|
|
|
574
650
|
|
|
575
651
|
### `mdbkit loginfo <log>`
|
|
576
652
|
|
|
577
|
-
Overall log summary: server version,
|
|
578
|
-
|
|
653
|
+
Overall log summary: server version, what wrote the log (replica set
|
|
654
|
+
member, standalone, mongos, shard or config server, and its replica set),
|
|
655
|
+
host, restarts, connections accepted, slow-query count, still-running
|
|
656
|
+
operations (8.3+), chunk migrations (on a shard), warning/error counts, and a
|
|
657
|
+
per-component line breakdown.
|
|
579
658
|
|
|
580
659
|
| Option | Description |
|
|
581
660
|
|---|---|
|
|
@@ -620,6 +699,14 @@ included even though no index can speed up an insert: a slow insert is still
|
|
|
620
699
|
latency your application saw, and on 8.0+ the `--shape` view says whether it
|
|
621
700
|
was executing or waiting (on locks, flow control or write concern).
|
|
622
701
|
|
|
702
|
+
**On a mongos (router) log** the table changes: a router records how each
|
|
703
|
+
query was routed but not its plan (the shards have that), so `docsEx`,
|
|
704
|
+
`scan` and `plan` give way to `shards` (how many shards each execution went
|
|
705
|
+
to), `to all` (executions sent to every shard: scatter-gather) and
|
|
706
|
+
`shard wait` (the share of time spent waiting for the shards). Cluster
|
|
707
|
+
administration commands (`moveRange`, `shardCollection`, ...) are left out;
|
|
708
|
+
`triage` on the shard logs reports migrations.
|
|
709
|
+
|
|
623
710
|
```bash
|
|
624
711
|
mdbkit queries mongod.log
|
|
625
712
|
mdbkit queries mongod.log --sort scanRatio --limit 10
|
|
@@ -716,13 +803,14 @@ it chains with other tools (including mdbkit itself).
|
|
|
716
803
|
|
|
717
804
|
| Option | Description |
|
|
718
805
|
|---|---|
|
|
719
|
-
| `--component NAME` | `COMMAND`, `NETWORK`, `REPL`, `STORAGE`, `INDEX`, `WRITE`, `QUERY`, `CONTROL`, … |
|
|
806
|
+
| `--component NAME` | `COMMAND`, `NETWORK`, `REPL`, `ELECTION`, `STORAGE`, `INDEX`, `WRITE`, `QUERY`, `SHARDING`, `CONTROL`, … |
|
|
720
807
|
| `--severity S` | `I` info, `W` warning, `E` error, `F` fatal |
|
|
721
808
|
| `--ns NAMESPACE` | Exact namespace, e.g. `shop.orders` |
|
|
722
809
|
| `--slow N` | Only operations with `durationMillis` >= N |
|
|
723
810
|
| `--from TIMESTAMP` | Lower time bound (inclusive) |
|
|
724
811
|
| `--to TIMESTAMP` | Upper time bound (inclusive) |
|
|
725
812
|
| `--msg TEXT` | Substring match on the message field |
|
|
813
|
+
| `--failed` | Only operations that ended in an error (logged with an `errName`) |
|
|
726
814
|
| `--limit N` | Print only the **first** N matches |
|
|
727
815
|
| `--last N` | Print only the **last** N matches — usually what you want during an incident |
|
|
728
816
|
| `--as-explain` | Rebuild each matching slow query as a runnable `mongosh` `.explain()` command instead of printing the raw log line |
|
|
@@ -743,7 +831,7 @@ it chains with other tools (including mdbkit itself).
|
|
|
743
831
|
mdbkit filter mongod.log --severity E --last 20 # errors (most recent 20)
|
|
744
832
|
mdbkit filter mongod.log --severity F # fatal — always investigate
|
|
745
833
|
mdbkit filter mongod.log --severity W --last 50 # warnings
|
|
746
|
-
mdbkit filter mongod.log --component
|
|
834
|
+
mdbkit filter mongod.log --component ELECTION # elections and stepdowns
|
|
747
835
|
mdbkit filter mongod.log --slow 500 --ns shop.orders --limit 50
|
|
748
836
|
mdbkit filter mongod.log --from 2026-07-01T14:30:00+04:00 --to 2026-07-01T15:00:00+04:00
|
|
749
837
|
mdbkit filter mongod.log --slow 100 | mdbkit queries -
|
|
@@ -758,8 +846,8 @@ mdbkit filter mongod.log --ns shop.orders --slow 500 --last 3 --as-explain
|
|
|
758
846
|
|
|
759
847
|
# Or produce a runnable script, get the plan, and analyze it
|
|
760
848
|
mdbkit filter mongod.log --slow 500 --last 1 --as-explain --explain-script > q.js
|
|
761
|
-
mongosh --quiet --host your_db_host --username your_username
|
|
762
|
-
--password your_password --authenticationDatabase admin
|
|
849
|
+
mongosh --quiet --host your_db_host --username your_username \
|
|
850
|
+
--password your_password --authenticationDatabase admin \
|
|
763
851
|
--eval "$(cat q.js)" > explain.json
|
|
764
852
|
mdbkit explain explain.json
|
|
765
853
|
```
|
|
@@ -814,13 +902,13 @@ help — a candidate index from the same advisor engine.
|
|
|
814
902
|
|
|
815
903
|
```bash
|
|
816
904
|
# 1. Capture the plan (adjust host/credentials for your deployment)
|
|
817
|
-
mongosh --quiet
|
|
818
|
-
--host your_db_host
|
|
819
|
-
--port 27017
|
|
820
|
-
--username your_username
|
|
821
|
-
--password your_password
|
|
822
|
-
--authenticationDatabase admin
|
|
823
|
-
--eval 'EJSON.stringify(db.getSiblingDB("shop").orders.find({status:"open"}).sort({ts:-1}).explain("executionStats"))'
|
|
905
|
+
mongosh --quiet \
|
|
906
|
+
--host your_db_host \
|
|
907
|
+
--port 27017 \
|
|
908
|
+
--username your_username \
|
|
909
|
+
--password your_password \
|
|
910
|
+
--authenticationDatabase admin \
|
|
911
|
+
--eval 'EJSON.stringify(db.getSiblingDB("shop").orders.find({status:"open"}).sort({ts:-1}).explain("executionStats"))' \
|
|
824
912
|
> explain.json
|
|
825
913
|
|
|
826
914
|
# 2. Analyze it
|
|
@@ -851,7 +939,10 @@ one screen that says what happened, how bad it is, and where to look next.
|
|
|
851
939
|
| `--window N` | 60 | Analyze the last N minutes of log time; `0` = the whole file |
|
|
852
940
|
| `--dbpath PATH` | auto | Override the data directory used for the disk check |
|
|
853
941
|
| `--no-sysprobe` | off | Skip local disk/memory/CPU probes — use when analyzing a log copied off the host |
|
|
854
|
-
| `--ftdc PATH` | | `diagnostic.data` directory — adds CPU, memory, cache,
|
|
942
|
+
| `--ftdc PATH` | | `diagnostic.data` directory — adds CPU, memory, cache, checkpoint, eviction, flow-control and connection history from MongoDB's own recorder. Found automatically when the log is from this host (a mongos keeps it next to its log) |
|
|
943
|
+
| `--oslog FILE...` | | System log(s): OOM kills, file-descriptor limits and I/O errors that the mongod log cannot record |
|
|
944
|
+
| `--only LEVELS` | | Show only these severities, e.g. `--only CRIT,WARN` |
|
|
945
|
+
| `--exit-code` | | Exit 2 on CRIT, 1 on WARN, else 0 |
|
|
855
946
|
| `--report FILE` | | Write a shareable `.md` or `.html` report instead of terminal output |
|
|
856
947
|
| `--json` | | Machine-readable output |
|
|
857
948
|
|
|
@@ -867,8 +958,33 @@ mdbkit triage mongod.log --window 0 --no-sysprobe
|
|
|
867
958
|
with no clean shutdown before it is a CRIT, because that is what a crash,
|
|
868
959
|
`kill -9` or OOM kill looks like. mongod itself records whether its previous
|
|
869
960
|
shutdown was clean, so mdbkit can tell even when the crash happened before
|
|
870
|
-
the log you are reading begins.
|
|
871
|
-
|
|
961
|
+
the log you are reading begins.
|
|
962
|
+
|
|
963
|
+
**Elections.** An election because a member saw no primary is a CRIT: the
|
|
964
|
+
primary was lost (crash, kill, hang or network). A stepdown command ("step
|
|
965
|
+
up request") or a higher-priority member taking over is a WARN, worded as
|
|
966
|
+
probably deliberate. The first election of a newly initiated replica set is
|
|
967
|
+
INFO, not instability.
|
|
968
|
+
|
|
969
|
+
**Flow control, cache pressure and checkpoints.** Flow control is read from
|
|
970
|
+
the log (MongoDB warns every 10 seconds while it throttles writes) and from
|
|
971
|
+
FTDC (how long it was engaged and how long writers waited). Cache pressure
|
|
972
|
+
comes from FTDC: how long the cache sat past the points where application
|
|
973
|
+
threads must help evict (95% full or 20% dirty), and how much time they
|
|
974
|
+
spent evicting in the busiest minute. A slow checkpoint is a WARN past 60
|
|
975
|
+
seconds; FTDC records every checkpoint's duration, and MongoDB 8.3+ also
|
|
976
|
+
logs one that runs past 20 seconds. Each of these was checked on real 6.0,
|
|
977
|
+
7.0, 8.0 and 9.0 servers driven into that state.
|
|
978
|
+
|
|
979
|
+
**Sharded clusters.** On a mongos log, `triage` reports queries sent to every
|
|
980
|
+
shard (scatter-gather), time spent waiting on the shards, routing-table
|
|
981
|
+
refreshes, and shards or members the router could not reach. On a shard's
|
|
982
|
+
log it reports chunk migrations (how many, how much data, and why any
|
|
983
|
+
failed, e.g. waiting for the range deleter); on the config server's,
|
|
984
|
+
balancer errors. On any log, **failed operations** on your collections (a
|
|
985
|
+
query or write that ended in an error such as
|
|
986
|
+
`FailedToSatisfyReadPreference` or `MaxTimeMSExpired`) are grouped by
|
|
987
|
+
error; `mdbkit filter <log> --failed` prints them.
|
|
872
988
|
|
|
873
989
|
**Hosts running several mongods.** `triage` reads one instance's log; don't
|
|
874
990
|
pass several instances' logs to it, because several files are read as one
|
|
@@ -910,7 +1026,9 @@ startup line.
|
|
|
910
1026
|
**Per instance:** replica set, version, role, WiredTiger cache size, starts
|
|
911
1027
|
and crashes (unclean stops), slow operations and their total time, the share
|
|
912
1028
|
of that time spent waiting (8.0+), and its worst finding from the same
|
|
913
|
-
detectors `triage` uses.
|
|
1029
|
+
detectors `triage` uses. Shard and config server members are labelled as
|
|
1030
|
+
such, and a mongos on the same host gets a line of its own (it has no cache,
|
|
1031
|
+
so it is left out of the cache total).
|
|
914
1032
|
|
|
915
1033
|
**For the host:**
|
|
916
1034
|
|
|
@@ -983,7 +1101,7 @@ not encrypted; mdbkit decodes it offline.
|
|
|
983
1101
|
| `--all` | off | Analyze the entire history (see the performance note below) |
|
|
984
1102
|
| `--metric LABEL` | all | Restrict to one metric (repeatable), e.g. `--metric conns.current` |
|
|
985
1103
|
| `--step SECONDS` | 60 | Timeline bucket size |
|
|
986
|
-
| `--from` / `--to` | | Explicit time bounds (same formats as `filter`) |
|
|
1104
|
+
| `--from` / `--to` | | Explicit time bounds, UTC unless the value has an offset (same formats as `filter`) |
|
|
987
1105
|
| `--json` | | Machine-readable output |
|
|
988
1106
|
|
|
989
1107
|
**Performance note.** `diagnostic.data` can hold weeks of per-second samples —
|
|
@@ -1002,12 +1120,18 @@ mdbkit ftdc export diagnostic.data > metrics.csv
|
|
|
1002
1120
|
|
|
1003
1121
|
In `timeline`, gauges (connections, cache bytes, tickets) show the peak in
|
|
1004
1122
|
each bucket and cumulative counters (`ops.*`, `sys.cpu.*`) show their rate
|
|
1005
|
-
per second over it.
|
|
1123
|
+
per second over it. FTDC records time in UTC, and these commands show it as
|
|
1124
|
+
UTC; `triage --ftdc` converts it to the log's own time zone so the two line
|
|
1125
|
+
up.
|
|
1006
1126
|
|
|
1007
1127
|
Metric labels include `ops.*` (insert/query/update/delete/getmore/command),
|
|
1008
1128
|
`conns.current`, `conns.available`, `queue.readers`, `queue.writers`,
|
|
1009
1129
|
`cache.usedBytes`, `cache.maxBytes`, `cache.dirtyBytes`, `tickets.*`,
|
|
1010
|
-
`
|
|
1130
|
+
`checkpoint.lastMs`, `evict.appThreadMicros`, `flowControl.*`,
|
|
1131
|
+
`mem.residentMB`, and on Linux `sys.cpu.*` and `sys.mem.availableKB`. The
|
|
1132
|
+
same labels work across versions where MongoDB renamed the underlying
|
|
1133
|
+
statistic (checked on 6.0 to 9.0), and on 8.0+ shard servers and mongos,
|
|
1134
|
+
which group their metrics by role.
|
|
1011
1135
|
|
|
1012
1136
|
The data directory can be copied off the host and analyzed elsewhere — it
|
|
1013
1137
|
contains metrics only, never document contents.
|
|
@@ -1032,16 +1156,17 @@ Markdown output looks like this:
|
|
|
1032
1156
|
```markdown
|
|
1033
1157
|
# MongoDB incident triage
|
|
1034
1158
|
|
|
1035
|
-
*window 2026-07-01 08:
|
|
1159
|
+
*window 2026-07-01 08:29 -> 09:29 · generated 2026-07-01 09:31*
|
|
1036
1160
|
|
|
1037
1161
|
## Findings
|
|
1038
1162
|
|
|
1039
|
-
- **[CRIT] Replica set instability** —
|
|
1040
|
-
- Starting an election, since we've seen no PRIMARY in election timeout period
|
|
1041
|
-
-
|
|
1042
|
-
-
|
|
1043
|
-
|
|
1044
|
-
-
|
|
1163
|
+
- **[CRIT] Replica set instability** — 2 election/stepdown event(s); at least once a member saw no primary and called an election, which is what losing the primary (crash, kill, hang or network) looks like.
|
|
1164
|
+
- 08:50:32 Starting an election, since we've seen no PRIMARY in election timeout period
|
|
1165
|
+
- 08:50:34 Election succeeded, assuming primary role
|
|
1166
|
+
- *next:* `Find why the primary went away at the first timestamp: its own log (mdbkit triage on it), then the OS log (mdbkit oslog) for OOM kills or restarts.`
|
|
1167
|
+
- **[WARN] Connection storm** — 1 minute(s) at >= 60 new connections/min (baseline median 0/min); peak 220 at 08:49.
|
|
1168
|
+
- 10.20.9.77: 220 in the peak minute
|
|
1169
|
+
- *next:* `Identify the client: mdbkit connections <log> — look for pool misconfiguration or crash-loop reconnects.`
|
|
1045
1170
|
- **[OK] Errors** — No error/fatal severity lines in window.
|
|
1046
1171
|
```
|
|
1047
1172
|
|
|
@@ -1090,12 +1215,12 @@ or rehearsing a demo. This is the only command that starts external
|
|
|
1090
1215
|
processes; see [SECURITY.md](SECURITY.md) for exactly how it is bounded.
|
|
1091
1216
|
|
|
1092
1217
|
Requires `mongod` on your `PATH` (and `mongosh` to initiate the replica set
|
|
1093
|
-
and seed data). Linux and macOS.
|
|
1218
|
+
and seed data; a sharded lab also needs `mongos`). Linux and macOS.
|
|
1094
1219
|
|
|
1095
1220
|
| Action | What it does |
|
|
1096
1221
|
|---|---|
|
|
1097
|
-
| `start` | Create and start a replica set, print the connection string and log paths |
|
|
1098
|
-
| `seed` | Insert sample data and run a workload with deliberately interesting queries |
|
|
1222
|
+
| `start` | Create and start a replica set (or standalone, or sharded cluster), print the connection string and log paths. On an existing lab, start the nodes that are down, with their data and ports (options that would make a different lab are refused) |
|
|
1223
|
+
| `seed` | Insert sample data and run a workload with deliberately interesting queries (`--workload-only`: just the queries, on the data already there) |
|
|
1099
1224
|
| `status` | Show ports, pids and whether each node is running |
|
|
1100
1225
|
| `logs` | Print the log file paths, ready to pipe into other commands |
|
|
1101
1226
|
| `stop` | Stop the nodes, keep the data |
|
|
@@ -1104,11 +1229,13 @@ and seed data). Linux and macOS.
|
|
|
1104
1229
|
| Option | Default | Description |
|
|
1105
1230
|
|---|---|---|
|
|
1106
1231
|
| `--dir PATH` | `~/.mdbkit-lab` | Where the lab lives |
|
|
1107
|
-
| `--nodes N` | 3 | Replica set size |
|
|
1232
|
+
| `--nodes N` | 3 | Replica set size (with `--shards`: each shard's replica set, default 1) |
|
|
1233
|
+
| `--shards N` | | A sharded cluster with N shards, a config server and a mongos |
|
|
1108
1234
|
| `--port N` | 28110 | Base port — deliberately far from 27017 |
|
|
1109
1235
|
| `--slowms N` | 0 | Log every operation, which is what makes the log worth reading |
|
|
1110
1236
|
| `--standalone` | off | Single node, no replica set |
|
|
1111
1237
|
| `--docs N` | 50000 | Documents inserted by `seed` |
|
|
1238
|
+
| `--workload-only` | | `seed` runs the queries again on the data already there |
|
|
1112
1239
|
| `--yes` | | Confirm `destroy` |
|
|
1113
1240
|
|
|
1114
1241
|
**The full loop:**
|
|
@@ -1132,11 +1259,25 @@ mdbkit lab logs
|
|
|
1132
1259
|
# /home/you/.mdbkit-lab/node1/mongod.log
|
|
1133
1260
|
# /home/you/.mdbkit-lab/node2/mongod.log
|
|
1134
1261
|
|
|
1135
|
-
mdbkit queries $(mdbkit lab logs | head -1) #
|
|
1262
|
+
mdbkit queries $(mdbkit lab logs | head -1) # node0, the preferred primary
|
|
1136
1263
|
mdbkit triage $(mdbkit lab logs) # all three as one stream
|
|
1137
1264
|
mdbkit loginfo $(mdbkit lab logs | sed -n 2p) # a specific secondary
|
|
1138
1265
|
```
|
|
1139
1266
|
|
|
1267
|
+
**A sharded cluster**: a config server, N single-node shards (`--nodes 3`
|
|
1268
|
+
makes each shard a three-node replica set) and a mongos. `seed` shards
|
|
1269
|
+
`shop.orders` on `customerId`, moves a range to every shard, then runs
|
|
1270
|
+
targeted and scatter-gather queries through mongos. `logs` lists the mongos
|
|
1271
|
+
log first:
|
|
1272
|
+
|
|
1273
|
+
```bash
|
|
1274
|
+
mdbkit lab start --shards 2 # config 28110, shards 28111-28112, mongos 28113
|
|
1275
|
+
mdbkit lab seed
|
|
1276
|
+
mdbkit queries $(mdbkit lab logs | head -1) # the router: shards per query
|
|
1277
|
+
mdbkit triage $(mdbkit lab logs | sed -n 3p) # a shard: migrations, its queries
|
|
1278
|
+
mdbkit lab destroy --yes
|
|
1279
|
+
```
|
|
1280
|
+
|
|
1140
1281
|
**A single node**, when you do not need replication. It starts faster, and
|
|
1141
1282
|
`start` works without `mongosh` (`seed` still needs it):
|
|
1142
1283
|
|
|
@@ -1167,22 +1308,39 @@ mdbkit lab start # back up with the same data
|
|
|
1167
1308
|
mdbkit lab status # ports, pids, running or not
|
|
1168
1309
|
```
|
|
1169
1310
|
|
|
1311
|
+
**Rehearse a failure.** Kill a node the way a crash or the OOM killer would,
|
|
1312
|
+
see what mdbkit makes of it, then bring it back. `start` on an existing lab
|
|
1313
|
+
starts only the nodes that are down, on their old ports:
|
|
1314
|
+
|
|
1315
|
+
```bash
|
|
1316
|
+
kill -9 $(cat ~/.mdbkit-lab/node0/mongod.pid) # the primary dies
|
|
1317
|
+
sleep 20 # the others elect a new one
|
|
1318
|
+
mdbkit lab start # node0 comes back
|
|
1319
|
+
mdbkit triage $(mdbkit lab logs) --window 0 # crash, failover, recovery
|
|
1320
|
+
```
|
|
1321
|
+
|
|
1170
1322
|
**A complete before/after experiment**, which is what `lab` is really for:
|
|
1171
1323
|
|
|
1172
1324
|
```bash
|
|
1173
1325
|
mdbkit lab start && mdbkit lab seed
|
|
1174
1326
|
cp $(mdbkit lab logs | head -1) before.log
|
|
1327
|
+
mongosh --port 28110 --quiet --eval 'db.adminCommand({logRotate: 1})' # start a fresh log
|
|
1175
1328
|
|
|
1176
1329
|
mongosh --port 28110 --eval \
|
|
1177
1330
|
'db.getSiblingDB("shop").orders.createIndex({status:1, createdAt:-1})'
|
|
1178
1331
|
|
|
1179
|
-
mdbkit lab seed
|
|
1332
|
+
mdbkit lab seed --workload-only # the same queries, now with the index
|
|
1180
1333
|
cp $(mdbkit lab logs | head -1) after.log
|
|
1181
1334
|
|
|
1182
1335
|
mdbkit compare before.log --after after.log
|
|
1183
1336
|
mdbkit lab destroy --yes
|
|
1184
1337
|
```
|
|
1185
1338
|
|
|
1339
|
+
`--workload-only` runs the queries again without reloading the data, so the
|
|
1340
|
+
index you added stays; a plain `seed` reloads and would drop it. Rotating the
|
|
1341
|
+
log keeps the second run's lines apart from the first's, because lab logs
|
|
1342
|
+
are appended to across restarts.
|
|
1343
|
+
|
|
1186
1344
|
`seed` runs indexed point lookups alongside deliberately unindexed queries —
|
|
1187
1345
|
an equality-plus-range-plus-sort with no supporting index, an aggregation
|
|
1188
1346
|
that scans the collection, and updates whose predicate has no index — so the
|
|
@@ -1191,8 +1349,9 @@ log immediately contains something worth analysing.
|
|
|
1191
1349
|
**Safety.** The lab binds to `127.0.0.1` only, refuses to use or delete any
|
|
1192
1350
|
directory it did not create, and never touches a MongoDB it did not start.
|
|
1193
1351
|
Before it signals a process it checks that the pid still belongs to one of
|
|
1194
|
-
its own `mongod`s
|
|
1195
|
-
stale pid file can never kill something
|
|
1352
|
+
its own `mongod`s or its `mongos` (the command line names the lab's data
|
|
1353
|
+
directory or log file), so a stale pid file can never kill something
|
|
1354
|
+
unrelated. `destroy` refuses to
|
|
1196
1355
|
delete data while a lab node is still running. If a port is already taken it
|
|
1197
1356
|
says so before starting anything. If a start fails halfway, the lab is left
|
|
1198
1357
|
in a state `mdbkit lab destroy --yes` can clean up, and the error says so.
|
|
@@ -1331,19 +1490,59 @@ duration moving by more than 20%.
|
|
|
1331
1490
|
|
|
1332
1491
|
---
|
|
1333
1492
|
|
|
1334
|
-
### `mdbkit
|
|
1493
|
+
### `mdbkit indexes <file>...`
|
|
1494
|
+
|
|
1495
|
+
Unused and redundant indexes, from what `mdbkit export-script indexes`
|
|
1496
|
+
exported (index definitions plus `$indexStats` usage counters).
|
|
1497
|
+
|
|
1498
|
+
| Option | Default | Description |
|
|
1499
|
+
|---|---|---|
|
|
1500
|
+
| `--ns NAMESPACE` | all | Only this collection |
|
|
1501
|
+
| `--min-days N` | 7 | Warn when the usage counters cover fewer days than this |
|
|
1502
|
+
| `--exit-code` | | Exit 1 when there is an unused or redundant index |
|
|
1503
|
+
| `--json` | | Machine-readable output |
|
|
1504
|
+
|
|
1505
|
+
```bash
|
|
1506
|
+
mdbkit indexes indexes.json
|
|
1507
|
+
mdbkit indexes primary.json secondary1.json secondary2.json # combine members
|
|
1508
|
+
mdbkit indexes indexes.json --ns shop.orders
|
|
1509
|
+
```
|
|
1510
|
+
|
|
1511
|
+
What it reports:
|
|
1512
|
+
|
|
1513
|
+
- **Unused:** no recorded use since the counters started.
|
|
1514
|
+
- **Redundant:** its key is a prefix of another index with the same
|
|
1515
|
+
collation, which can serve the same queries (`{a: 1}` when `{a: 1, b: 1}`
|
|
1516
|
+
exists). Partial, sparse and special (text, 2dsphere, hashed, wildcard)
|
|
1517
|
+
indexes are never treated as covering or covered.
|
|
1518
|
+
- **Not candidates:** `_id`, unique indexes (they enforce a constraint),
|
|
1519
|
+
TTL indexes (the TTL monitor's deletes do not count as use, checked on
|
|
1520
|
+
8.0 and 9.0), hidden indexes, and the index the shard key needs.
|
|
1521
|
+
|
|
1522
|
+
Usage counters are kept **per member** and **reset when a member restarts**.
|
|
1523
|
+
An index unused on the primary may serve reads on a secondary, and one used
|
|
1524
|
+
monthly can look unused after a week. So export from every member (or
|
|
1525
|
+
through mongos for a sharded cluster) and pass all the files, and check the
|
|
1526
|
+
counter window mdbkit prints. It never recommends dropping anything: it
|
|
1527
|
+
prints the `hideIndex` command, which makes the planner ignore the index
|
|
1528
|
+
while it is still maintained, so `unhideIndex` undoes it instantly.
|
|
1529
|
+
|
|
1530
|
+
---
|
|
1531
|
+
|
|
1532
|
+
### `mdbkit export-script {schema|indexes|serverstatus}`
|
|
1335
1533
|
|
|
1336
1534
|
Prints a small `mongosh` script to stdout. **mdbkit never connects to your
|
|
1337
1535
|
database**. You run these yourself, so you can read exactly what they do
|
|
1338
|
-
first.
|
|
1536
|
+
first. All are read-only. `schema` exports **field names and types only,
|
|
1339
1537
|
never document values**. `indexes` exports the index definitions from
|
|
1340
|
-
`getIndexes()
|
|
1341
|
-
values
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1538
|
+
`getIndexes()` (a partial index's filter expression can contain literal
|
|
1539
|
+
values) and, where your role allows `$indexStats`, how often each index has
|
|
1540
|
+
been used; through mongos it also records the shard keys.
|
|
1541
|
+
|
|
1542
|
+
`schema` and `indexes` cover **every database you can read** (`admin`,
|
|
1543
|
+
`config` and `local` skipped) and key collections by full namespace, so it
|
|
1544
|
+
does not matter which database mongosh connects to. To export one database
|
|
1545
|
+
only, set `ONLY_DB` at the top of the script. They write relaxed Extended
|
|
1347
1546
|
JSON, so 64-bit counters come out as plain numbers.
|
|
1348
1547
|
|
|
1349
1548
|
```bash
|
|
@@ -1359,41 +1558,42 @@ mdbkit export-script serverstatus > export_serverstatus.js
|
|
|
1359
1558
|
Terminal output is and will remain first-class — this tool is built for the
|
|
1360
1559
|
Linux box the database actually runs on.
|
|
1361
1560
|
|
|
1362
|
-
**
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
8.0
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1561
|
+
**v0.8 is a long-term release.** Nothing further is scheduled. Bug reports
|
|
1562
|
+
are still read, and misread log lines are still the most useful thing to
|
|
1563
|
+
send.
|
|
1564
|
+
|
|
1565
|
+
**Shipped in v0.8:**
|
|
1566
|
+
|
|
1567
|
+
* **Sharded clusters.** mongos logs show how many shards each query shape
|
|
1568
|
+
went to, which ones went to all of them, and the time spent waiting on
|
|
1569
|
+
shards and refreshing routing tables. Shard and config server logs show
|
|
1570
|
+
chunk migrations (with the reason when one fails), the range deleter, the
|
|
1571
|
+
balancer's errors, unreachable shards and failed application operations.
|
|
1572
|
+
FTDC from 8.0+ shard servers and mongos decodes. `mdbkit lab --shards N`
|
|
1573
|
+
builds a cluster to try it on.
|
|
1574
|
+
* **`mdbkit indexes`:** unused and redundant indexes from `$indexStats`,
|
|
1575
|
+
across replica set members or shards, with the reversible `hideIndex`
|
|
1576
|
+
command rather than a drop.
|
|
1577
|
+
* **The beta detectors checked against real failures.** Elections and
|
|
1578
|
+
stepdowns, flow control, cache pressure and slow checkpoints were
|
|
1579
|
+
reproduced on real MongoDB 6.0, 7.0, 8.0 and 9.0 servers (a killed
|
|
1580
|
+
primary, a stepdown, a connection storm, frozen secondaries, a small
|
|
1581
|
+
cache under load, a checkpoint held up for a minute), so none is labelled
|
|
1582
|
+
beta any more. That turned up real bugs, now fixed: flow control was never
|
|
1583
|
+
spotted in the log, a failover soon after a set was created was taken for
|
|
1584
|
+
its set-up, a stepdown was invisible on the primary that stepped down, and
|
|
1585
|
+
every chunk migration looked like a shutdown on the receiving shard.
|
|
1586
|
+
* `filter --failed`, `lab start` restarting only the nodes that are down,
|
|
1587
|
+
`lab seed --workload-only`, and FTDC checkpoint and eviction metrics under
|
|
1588
|
+
their 8.0 names.
|
|
1589
|
+
|
|
1590
|
+
**Shipped before:** v0.7's `host` (hosts running many mongods); v0.6.1's
|
|
1591
|
+
testing against real servers; v0.6's 8.x/9.0 log fields and `audit`; v0.5's
|
|
1592
|
+
`oslog` and `serverstatus`; v0.4's `compare`; v0.3's `demo` and `lab`; v0.2's
|
|
1593
|
+
FTDC decoding, incident triage and shareable reports.
|
|
1594
|
+
|
|
1595
|
+
**Ideas, not scheduled:** jumbo chunks and balancer windows; slow oplog
|
|
1596
|
+
application on secondaries; `lab` on Windows.
|
|
1397
1597
|
|
|
1398
1598
|
## Bugs, feature requests, questions
|
|
1399
1599
|
|