Keyhole is a tool to explore MongoDB deployments. Instructions are available at
For MongoDB JSON logs parsing, use the improved Hatchet project.
Build the Docker image from the Dockerfile:
docker build -t keyhole .Check the version:
docker run --rm keyhole --versionRun keyhole with a MongoDB connection string:
docker run --rm keyhole <connection_string>For example, to get cluster information:
docker run --rm keyhole -allinfo "mongodb://localhost:27017"If you need to save output files (e.g., HTML reports, BSON files), mount a volume:
docker run --rm \
-v $(pwd)/out:/home/simagix/out \
-v $(pwd)/html:/home/simagix/html \
keyhole -allinfo "mongodb://localhost:27017" -htmlThis will save output files to the out and html directories in your current working directory.
To analyze MongoDB log files, mount the directory containing your logs:
docker run --rm \
-v $(pwd)/logs:/home/simagix/logs \
keyhole -loginfo logs/mongod.logIf your MongoDB instance is running on the host machine, use --network host (Linux) or host.docker.internal (macOS/Windows):
Linux:
docker run --rm --network host keyhole -allinfo "mongodb://localhost:27017"macOS/Windows:
docker run --rm keyhole -allinfo "mongodb://host.docker.internal:27017"If you want to build from the local repository instead of the upstream, modify the Dockerfile to copy local files instead of cloning from GitHub.
- Go 1.18 or later installed on your system
- Git (for version information)
Build keyhole using the provided build script:
./build.shThis will create a binary at dist/keyhole. The script will also verify the build by running keyhole --version.
Alternatively, you can build it manually:
go build -o dist/keyhole main/keyhole.goAfter building, you can run keyhole directly:
./dist/keyhole -allinfo "mongodb://localhost:27017"To generate an HTML report with cluster information, use the -html flag:
./dist/keyhole -allinfo "mongodb://localhost:27017" -htmlThe HTML report will be saved in the html directory (created automatically if it doesn't exist). The file will be named based on your MongoDB connection string, for example: html/your-cluster-stats.html.
You can also generate HTML reports for other operations:
# Generate HTML report for cluster stats
./dist/keyhole -allinfo "mongodb://localhost:27017" -html
# Analyze logs and generate reports (if supported)
./dist/keyhole -loginfo mongod.logYou can also run keyhole directly from source without building a binary:
go run main/keyhole.go -allinfo "mongodb://localhost:27017" -htmlThis is useful for development and testing, but building the binary is recommended for production use.
When running locally, keyhole creates the following directories for output:
./html/- HTML reports and visualization files./out/- BSON data files and other outputs
These directories are created automatically in your current working directory.
This software is not supported by MongoDB, Inc. under any of their commercial support subscriptions or otherwise. Any usage of keyhole is at your own risk.
-allinfosupports high number of collections-loginfoincludes raw logs
- Supports ReadPreferenceTagSets
- Prints connected client information from all
mongodprocesses - Prints client information from a log file
- Compares two clusters using internal metadata
- Performs deep comparison of two clusters
