mdbkit 0.6.0__tar.gz → 0.7.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.6.0 → mdbkit-0.7.0}/PKG-INFO +170 -28
- {mdbkit-0.6.0 → mdbkit-0.7.0}/README.md +168 -26
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/__init__.py +1 -1
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/analysis.py +75 -5
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/audit.py +33 -2
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/cli.py +46 -1
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/demo.py +9 -3
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/ftdc.py +9 -0
- mdbkit-0.7.0/mdbkit/host.py +568 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/lab.py +33 -4
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/parser.py +8 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/render.py +74 -15
- mdbkit-0.7.0/mdbkit/scripts.py +123 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/serverstatus.py +3 -1
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/shelljson.py +14 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/triage.py +311 -41
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit.egg-info/PKG-INFO +170 -28
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit.egg-info/SOURCES.txt +3 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/pyproject.toml +2 -2
- mdbkit-0.7.0/tests/test_host.py +166 -0
- mdbkit-0.7.0/tests/test_real_servers.py +362 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_triage.py +4 -2
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_v060_hardening.py +1 -1
- mdbkit-0.6.0/mdbkit/scripts.py +0 -83
- {mdbkit-0.6.0 → mdbkit-0.7.0}/LICENSE +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/advisor.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/compare.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/explain.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/filtering.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/oslog.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/rebuild.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit/report.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit.egg-info/dependency_links.txt +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit.egg-info/entry_points.txt +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit.egg-info/requires.txt +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/mdbkit.egg-info/top_level.txt +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/setup.cfg +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_demo_lab.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_explain.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_ftdc.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_mdbkit.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_oslog_serverstatus.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.0}/tests/test_rebuild_report.py +0 -0
- {mdbkit-0.6.0 → mdbkit-0.7.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 structured logs: slow-query shapes, index advice, incident triage, startup configuration audit, FTDC decoding. A spiritual successor to mtools' log tools.
|
|
3
|
+
Version: 0.7.0
|
|
4
|
+
Summary: Offline toolkit for MongoDB 4.4 to 9.0 structured logs: slow-query shapes, index advice, incident triage, multi-instance host checks, 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
|
|
@@ -36,7 +36,7 @@ Dynamic: license-file
|
|
|
36
36
|
deterministic index advice, incident triage, a startup configuration audit,
|
|
37
37
|
and diagnostic-data decoding. For MongoDB 4.4 through 8.x and 9.0, from the
|
|
38
38
|
terminal, without connecting to anything.
|
|
39
|
-
**[
|
|
39
|
+
**[Tested against real MongoDB 9.0.2, 8.3.11, 8.0.32 and 7.0.43](#compatibility)**
|
|
40
40
|
(October 2026).
|
|
41
41
|
|
|
42
42
|
A spiritual successor to mtools' log tools, which never learned to read the
|
|
@@ -266,29 +266,43 @@ updates — upgrades are always explicit.
|
|
|
266
266
|
|
|
267
267
|
## Compatibility
|
|
268
268
|
|
|
269
|
-
**
|
|
270
|
-
|
|
271
|
-
format, so anything from **4.4** onwards
|
|
272
|
-
text logs and are not supported.
|
|
269
|
+
**Tested against (October 2026):** MongoDB **9.0.2**, **8.3.11**, **8.0.32**
|
|
270
|
+
(LTS) and **7.0.43** (LTS), the newest release in each series at the time.
|
|
271
|
+
mdbkit reads the structured JSON log format, so anything from **4.4** onwards
|
|
272
|
+
works; 4.2 and earlier wrote plain text logs and are not supported.
|
|
273
273
|
|
|
274
274
|
| MongoDB | What mdbkit uses from it |
|
|
275
275
|
|---|---|
|
|
276
276
|
| 4.4 – 7.0 | Everything except the 8.x-only fields below |
|
|
277
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 |
|
|
278
278
|
| 8.1+ | `<stage>Spills` / `<stage>SpilledBytes` (disk spills per stage) |
|
|
279
|
-
| 8.3+ |
|
|
280
|
-
| 9.0 |
|
|
281
|
-
|
|
282
|
-
When a field is missing
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
**How
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
279
|
+
| 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
|
+
| 9.0 | Same log fields as 8.3. Adds a few fields mdbkit does not use yet (`delinquencyInfo`, `queues.ingress`) |
|
|
281
|
+
|
|
282
|
+
When a field is missing because the log predates it, that part of the output
|
|
283
|
+
is left out. It is never guessed. FTDC decoding and `serverstatus` read
|
|
284
|
+
concurrency tickets from either the older `wiredTiger.concurrentTransactions`
|
|
285
|
+
or the newer `queues.execution` layout.
|
|
286
|
+
|
|
287
|
+
**How it was tested.** Official MongoDB builds of each version were run with
|
|
288
|
+
`mdbkit lab` (a three-node replica set and a standalone), seeded, and put
|
|
289
|
+
through a workload built to produce every field above: unindexed queries,
|
|
290
|
+
sorts and groups forced to spill to disk, writes blocked behind `fsyncLock` so
|
|
291
|
+
they wait rather than work, long-running server-side JavaScript, a clean
|
|
292
|
+
restart and a `kill -9`. Every mdbkit command was then run on the resulting
|
|
293
|
+
logs, `diagnostic.data`, serverStatus and explain output and `getLog`
|
|
294
|
+
captures, and compared with what the server actually did. Trimmed copies of
|
|
295
|
+
that output are in [`tests/fixtures/real/`](tests/fixtures/real/) and run with
|
|
296
|
+
every test.
|
|
297
|
+
|
|
298
|
+
> **Correction.** The 0.6.0 README and release notes said "last checked
|
|
299
|
+
> against 9.0.2, 8.3.13, 8.0.34 and 7.0.45". Three of those version numbers
|
|
300
|
+
> were wrong: MongoDB's release index has no 8.3.13, 8.0.34 or 7.0.45. That
|
|
301
|
+
> release was also checked against release notes and server source only, not
|
|
302
|
+
> a running server. Testing against real servers in 0.6.1 found several bugs
|
|
303
|
+
> 0.6.0 had missed (see the release notes).
|
|
304
|
+
|
|
305
|
+
If mdbkit misreads a line from your deployment, please
|
|
292
306
|
[open an issue](../../issues) with the line (redact as you like).
|
|
293
307
|
|
|
294
308
|
---
|
|
@@ -323,7 +337,7 @@ not help.
|
|
|
323
337
|
mdbkit export-script indexes > export_indexes.js
|
|
324
338
|
mdbkit export-script schema > export_schema.js
|
|
325
339
|
|
|
326
|
-
mongosh --quiet
|
|
340
|
+
mongosh --quiet "mongodb://your_db_host:27017/" \
|
|
327
341
|
--username your_username --password your_password \
|
|
328
342
|
--authenticationDatabase admin \
|
|
329
343
|
--eval "$(cat export_indexes.js)" > indexes.json # repeat for schema
|
|
@@ -425,6 +439,35 @@ Per-IP churn with first/last seen, plus an authenticated-users table showing
|
|
|
425
439
|
successful and failed logins per account and when each last authenticated —
|
|
426
440
|
the question that starts most access incidents.
|
|
427
441
|
|
|
442
|
+
### 7. Is this host running too many mongods for its memory?
|
|
443
|
+
|
|
444
|
+
```bash
|
|
445
|
+
mdbkit host /var/log/mongodb # every instance's log under here
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
```
|
|
449
|
+
== mdbkit host: 8 instance(s) on vm ==
|
|
450
|
+
last 1440 minutes of each log | 7.8 GiB RAM (this machine)
|
|
451
|
+
|
|
452
|
+
[CRIT] Cache sizes vs RAM: WiredTiger caches add up to 11.8 GiB, 150% of 7.8 GiB RAM (this machine).
|
|
453
|
+
[CRIT] Instances that crashed: 1 instance(s) started after an unclean stop (crash, kill -9 or OOM kill).
|
|
454
|
+
- 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). [...]
|
|
456
|
+
|
|
457
|
+
instance set version role cache starts crashes slow ops slow time waiting worst first issue
|
|
458
|
+
-------- ---- ------- ---------- ------- ------ ------- -------- --------- ------- ----- --------------------------
|
|
459
|
+
vm:29021 rs02 8.0.32 SECONDARY 256 MiB 2 1 0 - - CRIT Process start(s) in window
|
|
460
|
+
vm:29030 - 8.0.32 standalone 512 MiB 1 0 9 472ms 0% WARN Collection scans
|
|
461
|
+
vm:29010 rs01 8.0.32 PRIMARY 3.4 GiB 1 0 3 271ms 0% WARN Collection scans
|
|
462
|
+
[...]
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
For hosts that run many mongods side by side, typically one member of each
|
|
466
|
+
of many replica sets. The usual failure is that every instance was left on
|
|
467
|
+
the default WiredTiger cache, which assumes the machine is its alone; the
|
|
468
|
+
caches add up to several times the RAM and the OOM killer picks off
|
|
469
|
+
instances. (Output above is from a real 8-instance test host.)
|
|
470
|
+
|
|
428
471
|
---
|
|
429
472
|
|
|
430
473
|
## Running it on a schedule
|
|
@@ -570,6 +613,13 @@ query with different parameters is counted once.
|
|
|
570
613
|
| `plan` | The plan MongoDB chose: `COLLSCAN` (no index), `IXSCAN{fields}` (index used), `IDHACK` (`_id` lookup), `+SORT` (in-memory sort), `+SPILL` (wrote temporary files to disk). `?` = the plan was not recorded on that line |
|
|
571
614
|
| `shape` | Fields and operators queried, with the sort |
|
|
572
615
|
|
|
616
|
+
Two kinds of row are worth knowing about. A `getMore(find)` or
|
|
617
|
+
`getMore(aggregate)` row is a cursor fetching more results; it is grouped
|
|
618
|
+
under the shape of the query that opened the cursor. Slow `insert` rows are
|
|
619
|
+
included even though no index can speed up an insert: a slow insert is still
|
|
620
|
+
latency your application saw, and on 8.0+ the `--shape` view says whether it
|
|
621
|
+
was executing or waiting (on locks, flow control or write concern).
|
|
622
|
+
|
|
573
623
|
```bash
|
|
574
624
|
mdbkit queries mongod.log
|
|
575
625
|
mdbkit queries mongod.log --sort scanRatio --limit 10
|
|
@@ -813,6 +863,73 @@ mdbkit triage mongod.log --report incident.html
|
|
|
813
863
|
mdbkit triage mongod.log --window 0 --no-sysprobe
|
|
814
864
|
```
|
|
815
865
|
|
|
866
|
+
**Restarts and crashes.** A restart after a clean shutdown is a WARN; a start
|
|
867
|
+
with no clean shutdown before it is a CRIT, because that is what a crash,
|
|
868
|
+
`kill -9` or OOM kill looks like. mongod itself records whether its previous
|
|
869
|
+
shutdown was clean, so mdbkit can tell even when the crash happened before
|
|
870
|
+
the log you are reading begins. The first election of a newly initiated
|
|
871
|
+
replica set is reported as INFO, not as instability.
|
|
872
|
+
|
|
873
|
+
**Hosts running several mongods.** `triage` reads one instance's log; don't
|
|
874
|
+
pass several instances' logs to it, because several files are read as one
|
|
875
|
+
stream (that is for the rotated logs of one instance, or the members of one
|
|
876
|
+
replica set). For the whole host at once, use [`mdbkit host`](#mdbkit-host-logs).
|
|
877
|
+
When several mongods run on the host, `triage` uses the pid and dbPath the
|
|
878
|
+
log records (in its startup line, or at the top of a rotated file) to pick
|
|
879
|
+
the right process for its memory, uptime and disk checks, and when
|
|
880
|
+
`--oslog` shows an OOM kill it says whether the killed pid was this
|
|
881
|
+
instance or another one.
|
|
882
|
+
|
|
883
|
+
---
|
|
884
|
+
|
|
885
|
+
### `mdbkit host <logs...>`
|
|
886
|
+
|
|
887
|
+
One host running many mongod instances: one line per instance, and checks
|
|
888
|
+
that only make sense for the host as a whole.
|
|
889
|
+
|
|
890
|
+
| Option | Default | Description |
|
|
891
|
+
|---|---|---|
|
|
892
|
+
| `--window N` | 1440 | Analyze the last N minutes of each log; `0` = whole logs |
|
|
893
|
+
| `--ram SIZE` | | The host's memory (`64G`, `65536M`) when the logs were copied off it. On the host it is read from `/proc` |
|
|
894
|
+
| `--oslog FILE...` | | System log(s): each OOM kill is matched to the instance it killed |
|
|
895
|
+
| `--limit N` | all | Show only the N worst instances |
|
|
896
|
+
| `--exit-code` | | Exit 2 on CRIT, 1 on WARN, else 0 |
|
|
897
|
+
| `--json` | | Machine-readable output |
|
|
898
|
+
|
|
899
|
+
```bash
|
|
900
|
+
mdbkit host /var/log/mongodb # finds every *.log* below
|
|
901
|
+
mdbkit host /var/log/mongodb --oslog /var/log/syslog # who did the OOM killer hit?
|
|
902
|
+
mdbkit host "/mnt/copied/db7/*/mongod.log*" --ram 256G --limit 15
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
Give it files, globs or directories (searched three levels deep, never into
|
|
906
|
+
a data directory). Files are grouped into instances by the host and port the
|
|
907
|
+
log records, so rotated files join their instance even though they have no
|
|
908
|
+
startup line.
|
|
909
|
+
|
|
910
|
+
**Per instance:** replica set, version, role, WiredTiger cache size, starts
|
|
911
|
+
and crashes (unclean stops), slow operations and their total time, the share
|
|
912
|
+
of that time spent waiting (8.0+), and its worst finding from the same
|
|
913
|
+
detectors `triage` uses.
|
|
914
|
+
|
|
915
|
+
**For the host:**
|
|
916
|
+
|
|
917
|
+
- **Cache sizes vs RAM.** Each instance's cache comes from its own log
|
|
918
|
+
("Opening WiredTiger" states the size, even when it is the default). The
|
|
919
|
+
total is compared with the RAM: WARN above 60%, CRIT above 85%. These are
|
|
920
|
+
rules of thumb: MongoDB's single-instance default is about half the RAM,
|
|
921
|
+
leaving the rest to the OS file cache and each process's connections,
|
|
922
|
+
sorts and aggregations.
|
|
923
|
+
- **Default cache on a shared host.** Instances without `cacheSizeGB` each
|
|
924
|
+
assume the whole machine is theirs.
|
|
925
|
+
- **Crashes** across all instances, and with `--oslog`, every OOM kill
|
|
926
|
+
matched to the instance it hit by pid.
|
|
927
|
+
- **Startup warnings counted across instances.** Kernel and limit settings
|
|
928
|
+
belong to the host, so "Open-file limit is too low: 54 of 54 instances" is
|
|
929
|
+
one fix, not 54.
|
|
930
|
+
- **On the host itself:** instances with a log but no running mongod, and
|
|
931
|
+
running mongods whose logs were not given.
|
|
932
|
+
|
|
816
933
|
---
|
|
817
934
|
|
|
818
935
|
### `mdbkit audit <log>`
|
|
@@ -883,6 +1000,10 @@ mdbkit ftdc timeline diagnostic.data --metric conns.current --step 300
|
|
|
883
1000
|
mdbkit ftdc export diagnostic.data > metrics.csv
|
|
884
1001
|
```
|
|
885
1002
|
|
|
1003
|
+
In `timeline`, gauges (connections, cache bytes, tickets) show the peak in
|
|
1004
|
+
each bucket and cumulative counters (`ops.*`, `sys.cpu.*`) show their rate
|
|
1005
|
+
per second over it.
|
|
1006
|
+
|
|
886
1007
|
Metric labels include `ops.*` (insert/query/update/delete/getmore/command),
|
|
887
1008
|
`conns.current`, `conns.available`, `queue.readers`, `queue.writers`,
|
|
888
1009
|
`cache.usedBytes`, `cache.maxBytes`, `cache.dirtyBytes`, `tickets.*`,
|
|
@@ -1016,8 +1137,8 @@ mdbkit triage $(mdbkit lab logs) # all three as one stream
|
|
|
1016
1137
|
mdbkit loginfo $(mdbkit lab logs | sed -n 2p) # a specific secondary
|
|
1017
1138
|
```
|
|
1018
1139
|
|
|
1019
|
-
**A single node**, when you do not need replication
|
|
1020
|
-
|
|
1140
|
+
**A single node**, when you do not need replication. It starts faster, and
|
|
1141
|
+
`start` works without `mongosh` (`seed` still needs it):
|
|
1021
1142
|
|
|
1022
1143
|
```bash
|
|
1023
1144
|
mdbkit lab start --standalone
|
|
@@ -1150,7 +1271,9 @@ role and process memory. Tickets are read from either the older
|
|
|
1150
1271
|
mongosh prints when you run `db.serverStatus()` and copy the output:
|
|
1151
1272
|
unquoted keys, `Long('42')`, `ISODate(...)`, `Timestamp({...})`. A file
|
|
1152
1273
|
redirected in Windows PowerShell (UTF-16) works too. Nothing in the file is
|
|
1153
|
-
ever evaluated; it is tokenised as data.
|
|
1274
|
+
ever evaluated; it is tokenised as data. Dumps taken with the 0.6.0 export
|
|
1275
|
+
script, which wrote 64-bit counters as `{"low": …, "high": …}` objects, are
|
|
1276
|
+
read correctly too.
|
|
1154
1277
|
|
|
1155
1278
|
**Two dumps give true rates.** Almost everything in serverStatus is cumulative
|
|
1156
1279
|
since process start, so a single dump only yields lifetime averages:
|
|
@@ -1211,13 +1334,22 @@ duration moving by more than 20%.
|
|
|
1211
1334
|
### `mdbkit export-script {schema|indexes}`
|
|
1212
1335
|
|
|
1213
1336
|
Prints a small `mongosh` script to stdout. **mdbkit never connects to your
|
|
1214
|
-
database
|
|
1215
|
-
first. Both are read-only
|
|
1216
|
-
document values**.
|
|
1337
|
+
database**. You run these yourself, so you can read exactly what they do
|
|
1338
|
+
first. Both are read-only. `schema` exports **field names and types only,
|
|
1339
|
+
never document values**. `indexes` exports the index definitions from
|
|
1340
|
+
`getIndexes()`; a partial index's filter expression can contain literal
|
|
1341
|
+
values.
|
|
1342
|
+
|
|
1343
|
+
Both cover **every database you can read** (`admin`, `config` and `local`
|
|
1344
|
+
skipped) and key collections by full namespace, so it does not matter which
|
|
1345
|
+
database mongosh connects to. To export one database only, set `ONLY_DB` at
|
|
1346
|
+
the top of the script. The `serverstatus` script writes relaxed Extended
|
|
1347
|
+
JSON, so 64-bit counters come out as plain numbers.
|
|
1217
1348
|
|
|
1218
1349
|
```bash
|
|
1219
1350
|
mdbkit export-script indexes > export_indexes.js
|
|
1220
1351
|
mdbkit export-script schema > export_schema.js
|
|
1352
|
+
mdbkit export-script serverstatus > export_serverstatus.js
|
|
1221
1353
|
```
|
|
1222
1354
|
|
|
1223
1355
|
---
|
|
@@ -1227,6 +1359,15 @@ mdbkit export-script schema > export_schema.js
|
|
|
1227
1359
|
Terminal output is and will remain first-class — this tool is built for the
|
|
1228
1360
|
Linux box the database actually runs on.
|
|
1229
1361
|
|
|
1362
|
+
**Shipped in v0.7:** `mdbkit host`, for hosts running many mongods: one
|
|
1363
|
+
line per instance, cache sizes added up against RAM, crashes and OOM kills
|
|
1364
|
+
per instance, startup warnings counted across instances. Rotated logs are
|
|
1365
|
+
tied to their process.
|
|
1366
|
+
|
|
1367
|
+
**Shipped in v0.6.1:** tested against real MongoDB 7.0, 8.0, 8.3 and 9.0
|
|
1368
|
+
servers, with the bugs that turned up fixed; crash vs clean restart
|
|
1369
|
+
detection; correct behaviour on hosts running many mongods.
|
|
1370
|
+
|
|
1230
1371
|
**Shipped in v0.6:** MongoDB 8.x/9.0 support (executing vs waiting time,
|
|
1231
1372
|
query shape hashes, disk spills, peak memory, in-progress operations, the
|
|
1232
1373
|
8.0 ticket layout in FTDC), the `audit` command, mongosh-paste input, and a
|
|
@@ -1251,7 +1392,8 @@ Next up, roughly in order:
|
|
|
1251
1392
|
`docs/TESTING-PLAYBOOK.md`. Real logs and metrics very welcome.
|
|
1252
1393
|
|
|
1253
1394
|
mdbkit is validated against real-world structured logs (tens of thousands of
|
|
1254
|
-
lines) in addition to its synthetic test fixtures
|
|
1395
|
+
lines) in addition to its synthetic test fixtures, and its tests include real
|
|
1396
|
+
output from MongoDB 7.0.43, 8.0.32, 8.3.11 and 9.0.2.
|
|
1255
1397
|
|
|
1256
1398
|
## Bugs, feature requests, questions
|
|
1257
1399
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
deterministic index advice, incident triage, a startup configuration audit,
|
|
10
10
|
and diagnostic-data decoding. For MongoDB 4.4 through 8.x and 9.0, from the
|
|
11
11
|
terminal, without connecting to anything.
|
|
12
|
-
**[
|
|
12
|
+
**[Tested against real MongoDB 9.0.2, 8.3.11, 8.0.32 and 7.0.43](#compatibility)**
|
|
13
13
|
(October 2026).
|
|
14
14
|
|
|
15
15
|
A spiritual successor to mtools' log tools, which never learned to read the
|
|
@@ -239,29 +239,43 @@ updates — upgrades are always explicit.
|
|
|
239
239
|
|
|
240
240
|
## Compatibility
|
|
241
241
|
|
|
242
|
-
**
|
|
243
|
-
|
|
244
|
-
format, so anything from **4.4** onwards
|
|
245
|
-
text logs and are not supported.
|
|
242
|
+
**Tested against (October 2026):** MongoDB **9.0.2**, **8.3.11**, **8.0.32**
|
|
243
|
+
(LTS) and **7.0.43** (LTS), the newest release in each series at the time.
|
|
244
|
+
mdbkit reads the structured JSON log format, so anything from **4.4** onwards
|
|
245
|
+
works; 4.2 and earlier wrote plain text logs and are not supported.
|
|
246
246
|
|
|
247
247
|
| MongoDB | What mdbkit uses from it |
|
|
248
248
|
|---|---|
|
|
249
249
|
| 4.4 – 7.0 | Everything except the 8.x-only fields below |
|
|
250
250
|
| 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 |
|
|
251
251
|
| 8.1+ | `<stage>Spills` / `<stage>SpilledBytes` (disk spills per stage) |
|
|
252
|
-
| 8.3+ |
|
|
253
|
-
| 9.0 |
|
|
254
|
-
|
|
255
|
-
When a field is missing
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
**How
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
252
|
+
| 8.3+ | "Slow in-progress query" lines (id 1794200, component `SLOWPROG`), logged by default for operations still running after 5 s (`--defaultSlowInProgMS`), and `peakTrackedMemBytes` |
|
|
253
|
+
| 9.0 | Same log fields as 8.3. Adds a few fields mdbkit does not use yet (`delinquencyInfo`, `queues.ingress`) |
|
|
254
|
+
|
|
255
|
+
When a field is missing because the log predates it, that part of the output
|
|
256
|
+
is left out. It is never guessed. FTDC decoding and `serverstatus` read
|
|
257
|
+
concurrency tickets from either the older `wiredTiger.concurrentTransactions`
|
|
258
|
+
or the newer `queues.execution` layout.
|
|
259
|
+
|
|
260
|
+
**How it was tested.** Official MongoDB builds of each version were run with
|
|
261
|
+
`mdbkit lab` (a three-node replica set and a standalone), seeded, and put
|
|
262
|
+
through a workload built to produce every field above: unindexed queries,
|
|
263
|
+
sorts and groups forced to spill to disk, writes blocked behind `fsyncLock` so
|
|
264
|
+
they wait rather than work, long-running server-side JavaScript, a clean
|
|
265
|
+
restart and a `kill -9`. Every mdbkit command was then run on the resulting
|
|
266
|
+
logs, `diagnostic.data`, serverStatus and explain output and `getLog`
|
|
267
|
+
captures, and compared with what the server actually did. Trimmed copies of
|
|
268
|
+
that output are in [`tests/fixtures/real/`](tests/fixtures/real/) and run with
|
|
269
|
+
every test.
|
|
270
|
+
|
|
271
|
+
> **Correction.** The 0.6.0 README and release notes said "last checked
|
|
272
|
+
> against 9.0.2, 8.3.13, 8.0.34 and 7.0.45". Three of those version numbers
|
|
273
|
+
> were wrong: MongoDB's release index has no 8.3.13, 8.0.34 or 7.0.45. That
|
|
274
|
+
> release was also checked against release notes and server source only, not
|
|
275
|
+
> a running server. Testing against real servers in 0.6.1 found several bugs
|
|
276
|
+
> 0.6.0 had missed (see the release notes).
|
|
277
|
+
|
|
278
|
+
If mdbkit misreads a line from your deployment, please
|
|
265
279
|
[open an issue](../../issues) with the line (redact as you like).
|
|
266
280
|
|
|
267
281
|
---
|
|
@@ -296,7 +310,7 @@ not help.
|
|
|
296
310
|
mdbkit export-script indexes > export_indexes.js
|
|
297
311
|
mdbkit export-script schema > export_schema.js
|
|
298
312
|
|
|
299
|
-
mongosh --quiet
|
|
313
|
+
mongosh --quiet "mongodb://your_db_host:27017/" \
|
|
300
314
|
--username your_username --password your_password \
|
|
301
315
|
--authenticationDatabase admin \
|
|
302
316
|
--eval "$(cat export_indexes.js)" > indexes.json # repeat for schema
|
|
@@ -398,6 +412,35 @@ Per-IP churn with first/last seen, plus an authenticated-users table showing
|
|
|
398
412
|
successful and failed logins per account and when each last authenticated —
|
|
399
413
|
the question that starts most access incidents.
|
|
400
414
|
|
|
415
|
+
### 7. Is this host running too many mongods for its memory?
|
|
416
|
+
|
|
417
|
+
```bash
|
|
418
|
+
mdbkit host /var/log/mongodb # every instance's log under here
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
== mdbkit host: 8 instance(s) on vm ==
|
|
423
|
+
last 1440 minutes of each log | 7.8 GiB RAM (this machine)
|
|
424
|
+
|
|
425
|
+
[CRIT] Cache sizes vs RAM: WiredTiger caches add up to 11.8 GiB, 150% of 7.8 GiB RAM (this machine).
|
|
426
|
+
[CRIT] Instances that crashed: 1 instance(s) started after an unclean stop (crash, kill -9 or OOM kill).
|
|
427
|
+
- vm:29021: 1 unclean start(s)
|
|
428
|
+
[WARN] Default cache size on a shared host: 3 of 8 instances run with the default WiredTiger cache (cacheSizeGB not set). [...]
|
|
429
|
+
|
|
430
|
+
instance set version role cache starts crashes slow ops slow time waiting worst first issue
|
|
431
|
+
-------- ---- ------- ---------- ------- ------ ------- -------- --------- ------- ----- --------------------------
|
|
432
|
+
vm:29021 rs02 8.0.32 SECONDARY 256 MiB 2 1 0 - - CRIT Process start(s) in window
|
|
433
|
+
vm:29030 - 8.0.32 standalone 512 MiB 1 0 9 472ms 0% WARN Collection scans
|
|
434
|
+
vm:29010 rs01 8.0.32 PRIMARY 3.4 GiB 1 0 3 271ms 0% WARN Collection scans
|
|
435
|
+
[...]
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
For hosts that run many mongods side by side, typically one member of each
|
|
439
|
+
of many replica sets. The usual failure is that every instance was left on
|
|
440
|
+
the default WiredTiger cache, which assumes the machine is its alone; the
|
|
441
|
+
caches add up to several times the RAM and the OOM killer picks off
|
|
442
|
+
instances. (Output above is from a real 8-instance test host.)
|
|
443
|
+
|
|
401
444
|
---
|
|
402
445
|
|
|
403
446
|
## Running it on a schedule
|
|
@@ -543,6 +586,13 @@ query with different parameters is counted once.
|
|
|
543
586
|
| `plan` | The plan MongoDB chose: `COLLSCAN` (no index), `IXSCAN{fields}` (index used), `IDHACK` (`_id` lookup), `+SORT` (in-memory sort), `+SPILL` (wrote temporary files to disk). `?` = the plan was not recorded on that line |
|
|
544
587
|
| `shape` | Fields and operators queried, with the sort |
|
|
545
588
|
|
|
589
|
+
Two kinds of row are worth knowing about. A `getMore(find)` or
|
|
590
|
+
`getMore(aggregate)` row is a cursor fetching more results; it is grouped
|
|
591
|
+
under the shape of the query that opened the cursor. Slow `insert` rows are
|
|
592
|
+
included even though no index can speed up an insert: a slow insert is still
|
|
593
|
+
latency your application saw, and on 8.0+ the `--shape` view says whether it
|
|
594
|
+
was executing or waiting (on locks, flow control or write concern).
|
|
595
|
+
|
|
546
596
|
```bash
|
|
547
597
|
mdbkit queries mongod.log
|
|
548
598
|
mdbkit queries mongod.log --sort scanRatio --limit 10
|
|
@@ -786,6 +836,73 @@ mdbkit triage mongod.log --report incident.html
|
|
|
786
836
|
mdbkit triage mongod.log --window 0 --no-sysprobe
|
|
787
837
|
```
|
|
788
838
|
|
|
839
|
+
**Restarts and crashes.** A restart after a clean shutdown is a WARN; a start
|
|
840
|
+
with no clean shutdown before it is a CRIT, because that is what a crash,
|
|
841
|
+
`kill -9` or OOM kill looks like. mongod itself records whether its previous
|
|
842
|
+
shutdown was clean, so mdbkit can tell even when the crash happened before
|
|
843
|
+
the log you are reading begins. The first election of a newly initiated
|
|
844
|
+
replica set is reported as INFO, not as instability.
|
|
845
|
+
|
|
846
|
+
**Hosts running several mongods.** `triage` reads one instance's log; don't
|
|
847
|
+
pass several instances' logs to it, because several files are read as one
|
|
848
|
+
stream (that is for the rotated logs of one instance, or the members of one
|
|
849
|
+
replica set). For the whole host at once, use [`mdbkit host`](#mdbkit-host-logs).
|
|
850
|
+
When several mongods run on the host, `triage` uses the pid and dbPath the
|
|
851
|
+
log records (in its startup line, or at the top of a rotated file) to pick
|
|
852
|
+
the right process for its memory, uptime and disk checks, and when
|
|
853
|
+
`--oslog` shows an OOM kill it says whether the killed pid was this
|
|
854
|
+
instance or another one.
|
|
855
|
+
|
|
856
|
+
---
|
|
857
|
+
|
|
858
|
+
### `mdbkit host <logs...>`
|
|
859
|
+
|
|
860
|
+
One host running many mongod instances: one line per instance, and checks
|
|
861
|
+
that only make sense for the host as a whole.
|
|
862
|
+
|
|
863
|
+
| Option | Default | Description |
|
|
864
|
+
|---|---|---|
|
|
865
|
+
| `--window N` | 1440 | Analyze the last N minutes of each log; `0` = whole logs |
|
|
866
|
+
| `--ram SIZE` | | The host's memory (`64G`, `65536M`) when the logs were copied off it. On the host it is read from `/proc` |
|
|
867
|
+
| `--oslog FILE...` | | System log(s): each OOM kill is matched to the instance it killed |
|
|
868
|
+
| `--limit N` | all | Show only the N worst instances |
|
|
869
|
+
| `--exit-code` | | Exit 2 on CRIT, 1 on WARN, else 0 |
|
|
870
|
+
| `--json` | | Machine-readable output |
|
|
871
|
+
|
|
872
|
+
```bash
|
|
873
|
+
mdbkit host /var/log/mongodb # finds every *.log* below
|
|
874
|
+
mdbkit host /var/log/mongodb --oslog /var/log/syslog # who did the OOM killer hit?
|
|
875
|
+
mdbkit host "/mnt/copied/db7/*/mongod.log*" --ram 256G --limit 15
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
Give it files, globs or directories (searched three levels deep, never into
|
|
879
|
+
a data directory). Files are grouped into instances by the host and port the
|
|
880
|
+
log records, so rotated files join their instance even though they have no
|
|
881
|
+
startup line.
|
|
882
|
+
|
|
883
|
+
**Per instance:** replica set, version, role, WiredTiger cache size, starts
|
|
884
|
+
and crashes (unclean stops), slow operations and their total time, the share
|
|
885
|
+
of that time spent waiting (8.0+), and its worst finding from the same
|
|
886
|
+
detectors `triage` uses.
|
|
887
|
+
|
|
888
|
+
**For the host:**
|
|
889
|
+
|
|
890
|
+
- **Cache sizes vs RAM.** Each instance's cache comes from its own log
|
|
891
|
+
("Opening WiredTiger" states the size, even when it is the default). The
|
|
892
|
+
total is compared with the RAM: WARN above 60%, CRIT above 85%. These are
|
|
893
|
+
rules of thumb: MongoDB's single-instance default is about half the RAM,
|
|
894
|
+
leaving the rest to the OS file cache and each process's connections,
|
|
895
|
+
sorts and aggregations.
|
|
896
|
+
- **Default cache on a shared host.** Instances without `cacheSizeGB` each
|
|
897
|
+
assume the whole machine is theirs.
|
|
898
|
+
- **Crashes** across all instances, and with `--oslog`, every OOM kill
|
|
899
|
+
matched to the instance it hit by pid.
|
|
900
|
+
- **Startup warnings counted across instances.** Kernel and limit settings
|
|
901
|
+
belong to the host, so "Open-file limit is too low: 54 of 54 instances" is
|
|
902
|
+
one fix, not 54.
|
|
903
|
+
- **On the host itself:** instances with a log but no running mongod, and
|
|
904
|
+
running mongods whose logs were not given.
|
|
905
|
+
|
|
789
906
|
---
|
|
790
907
|
|
|
791
908
|
### `mdbkit audit <log>`
|
|
@@ -856,6 +973,10 @@ mdbkit ftdc timeline diagnostic.data --metric conns.current --step 300
|
|
|
856
973
|
mdbkit ftdc export diagnostic.data > metrics.csv
|
|
857
974
|
```
|
|
858
975
|
|
|
976
|
+
In `timeline`, gauges (connections, cache bytes, tickets) show the peak in
|
|
977
|
+
each bucket and cumulative counters (`ops.*`, `sys.cpu.*`) show their rate
|
|
978
|
+
per second over it.
|
|
979
|
+
|
|
859
980
|
Metric labels include `ops.*` (insert/query/update/delete/getmore/command),
|
|
860
981
|
`conns.current`, `conns.available`, `queue.readers`, `queue.writers`,
|
|
861
982
|
`cache.usedBytes`, `cache.maxBytes`, `cache.dirtyBytes`, `tickets.*`,
|
|
@@ -989,8 +1110,8 @@ mdbkit triage $(mdbkit lab logs) # all three as one stream
|
|
|
989
1110
|
mdbkit loginfo $(mdbkit lab logs | sed -n 2p) # a specific secondary
|
|
990
1111
|
```
|
|
991
1112
|
|
|
992
|
-
**A single node**, when you do not need replication
|
|
993
|
-
|
|
1113
|
+
**A single node**, when you do not need replication. It starts faster, and
|
|
1114
|
+
`start` works without `mongosh` (`seed` still needs it):
|
|
994
1115
|
|
|
995
1116
|
```bash
|
|
996
1117
|
mdbkit lab start --standalone
|
|
@@ -1123,7 +1244,9 @@ role and process memory. Tickets are read from either the older
|
|
|
1123
1244
|
mongosh prints when you run `db.serverStatus()` and copy the output:
|
|
1124
1245
|
unquoted keys, `Long('42')`, `ISODate(...)`, `Timestamp({...})`. A file
|
|
1125
1246
|
redirected in Windows PowerShell (UTF-16) works too. Nothing in the file is
|
|
1126
|
-
ever evaluated; it is tokenised as data.
|
|
1247
|
+
ever evaluated; it is tokenised as data. Dumps taken with the 0.6.0 export
|
|
1248
|
+
script, which wrote 64-bit counters as `{"low": …, "high": …}` objects, are
|
|
1249
|
+
read correctly too.
|
|
1127
1250
|
|
|
1128
1251
|
**Two dumps give true rates.** Almost everything in serverStatus is cumulative
|
|
1129
1252
|
since process start, so a single dump only yields lifetime averages:
|
|
@@ -1184,13 +1307,22 @@ duration moving by more than 20%.
|
|
|
1184
1307
|
### `mdbkit export-script {schema|indexes}`
|
|
1185
1308
|
|
|
1186
1309
|
Prints a small `mongosh` script to stdout. **mdbkit never connects to your
|
|
1187
|
-
database
|
|
1188
|
-
first. Both are read-only
|
|
1189
|
-
document values**.
|
|
1310
|
+
database**. You run these yourself, so you can read exactly what they do
|
|
1311
|
+
first. Both are read-only. `schema` exports **field names and types only,
|
|
1312
|
+
never document values**. `indexes` exports the index definitions from
|
|
1313
|
+
`getIndexes()`; a partial index's filter expression can contain literal
|
|
1314
|
+
values.
|
|
1315
|
+
|
|
1316
|
+
Both cover **every database you can read** (`admin`, `config` and `local`
|
|
1317
|
+
skipped) and key collections by full namespace, so it does not matter which
|
|
1318
|
+
database mongosh connects to. To export one database only, set `ONLY_DB` at
|
|
1319
|
+
the top of the script. The `serverstatus` script writes relaxed Extended
|
|
1320
|
+
JSON, so 64-bit counters come out as plain numbers.
|
|
1190
1321
|
|
|
1191
1322
|
```bash
|
|
1192
1323
|
mdbkit export-script indexes > export_indexes.js
|
|
1193
1324
|
mdbkit export-script schema > export_schema.js
|
|
1325
|
+
mdbkit export-script serverstatus > export_serverstatus.js
|
|
1194
1326
|
```
|
|
1195
1327
|
|
|
1196
1328
|
---
|
|
@@ -1200,6 +1332,15 @@ mdbkit export-script schema > export_schema.js
|
|
|
1200
1332
|
Terminal output is and will remain first-class — this tool is built for the
|
|
1201
1333
|
Linux box the database actually runs on.
|
|
1202
1334
|
|
|
1335
|
+
**Shipped in v0.7:** `mdbkit host`, for hosts running many mongods: one
|
|
1336
|
+
line per instance, cache sizes added up against RAM, crashes and OOM kills
|
|
1337
|
+
per instance, startup warnings counted across instances. Rotated logs are
|
|
1338
|
+
tied to their process.
|
|
1339
|
+
|
|
1340
|
+
**Shipped in v0.6.1:** tested against real MongoDB 7.0, 8.0, 8.3 and 9.0
|
|
1341
|
+
servers, with the bugs that turned up fixed; crash vs clean restart
|
|
1342
|
+
detection; correct behaviour on hosts running many mongods.
|
|
1343
|
+
|
|
1203
1344
|
**Shipped in v0.6:** MongoDB 8.x/9.0 support (executing vs waiting time,
|
|
1204
1345
|
query shape hashes, disk spills, peak memory, in-progress operations, the
|
|
1205
1346
|
8.0 ticket layout in FTDC), the `audit` command, mongosh-paste input, and a
|
|
@@ -1224,7 +1365,8 @@ Next up, roughly in order:
|
|
|
1224
1365
|
`docs/TESTING-PLAYBOOK.md`. Real logs and metrics very welcome.
|
|
1225
1366
|
|
|
1226
1367
|
mdbkit is validated against real-world structured logs (tens of thousands of
|
|
1227
|
-
lines) in addition to its synthetic test fixtures
|
|
1368
|
+
lines) in addition to its synthetic test fixtures, and its tests include real
|
|
1369
|
+
output from MongoDB 7.0.43, 8.0.32, 8.3.11 and 9.0.2.
|
|
1228
1370
|
|
|
1229
1371
|
## Bugs, feature requests, questions
|
|
1230
1372
|
|