Store logs in MongoDB¶
- Author:
Rohit Goswami
Overview¶
bless can store compressed log blobs in MongoDB alongside metadata (command,
duration, timestamps, label, UUID).
Prerequisites¶
A running MongoDB instance. Set the connection URI:
export MONGODB_URI="mongodb://localhost:27017"
Usage¶
bless --use-mongodb --label nightly-build -- make test
This:
Runs the command with logging as usual
Connects to MongoDB
Stores the gzip blob + metadata in the
local.commandscollection
Querying stored runs¶
mongosh --eval 'db.commands.find({label: "nightly-build"}).sort({start_time: -1}).limit(5)'
Filtering by MongoDB mode¶
When --use-mongodb is set, the gzip file only captures INFO and WARN levels
(not TRACE). This reduces storage for production use. Stdout still shows all
levels.