# Use -f/--filename to pass the file to emit JSON for
ruby dump_bson.rb -f auditLog_prod01.bson
....
{"atype":"authenticate","ts":"2020-11-21 06:25:22 UTC","local":{"ip":"127.0.0.1","port":27013},"remote":{"ip":"127.0.0.1","port":55842},"users":[{"user":"__system","db":"local"}],"roles":[],"param":{"user":"__system","db":"local","mechanism":"SCRAM-SHA-1"},"result":0}
{"atype":"shutdown","ts":"2020-11-21 06:25:23 UTC","local":{"ip":"127.0.0.1","port":27013},"remote":{"ip":"127.0.0.1","port":55842},"users":[{"user":"__system","db":"local"}],"roles":[],"param":{},"result":0}
# If there's a failure while parsing, the parser will break with an error indicating where the failure was
[pos: 62840087 len: 18415897] Attempted to read 18415897 bytes, but only 4170505 bytes remain
If there's an error, the position in the file (pos
in the output) can be used with the -s/--skip
parameter to restart at that position. This allows you to quickly resume without having to start over each time:
The -d/--debug
flag outputs a short summary of successful entries as well as their position and length details.
ruby dump_bson.rb -f auditLog_prod01.bson -s 62839609 -d
[pos: 62839609 len: 271] {"atype":"authenticate","ts":"2 ...
[pos: 62839880 len: 207] {"atype":"shutdown","ts":"2020- ...
[pos: 62840087 len: 18415897] Attempted to read 18415897 bytes, but only 4170505 bytes remain