Blackbox
live · 0.0.2internalOne place to find out what my server's containers have been saying.
What it is
Blackbox is a central place to collect and search the logs from the Docker containers running on my server.
Instead of looking through one container at a time, I can search across my projects and look back at what happened, even after a container has been replaced.
Why I made it
As I’ve built out my server, I’ve ended up making tools for most of the work involved in running it. Lighthouse handles deployments, Cove handles secrets, and Sonar tells me whether everything is healthy.
But when something went wrong, I was still digging through individual containers with docker logs and trying to piece together what happened.
That works until the container gets replaced, or the error you’re looking for happened in a different service than the one you’re checking.
I wanted one place to look through that history. Not another system for controlling my server, just a record of what my applications were doing when things worked and when they didn’t.
How it works
Blackbox watches the Docker containers on my server and collects the log output they already produce. It doesn’t require every project to use a special library. If Docker has the logs, Blackbox can collect them.
It runs as three parts. A small proxy is the only part with access to Docker’s socket. A collector reads the log streams, recognizes common formats, redacts some sensitive values, and stores the results in PostgreSQL. An authenticated API makes the stored logs searchable.
Each entry can be associated with its project, service, container, and version using Docker’s metadata. From the command-line interface, I can filter by those details, search for particular messages, or pull up the lines surrounding an error.
The collector also keeps track of where it left off, so an interruption doesn’t mean starting from scratch. When Docker logs are no longer available or appear damaged, Blackbox records a gap so I can tell the history might be incomplete.
Logs are kept for up to 30 days, subject to a storage limit. Blackbox only observes and records; it doesn’t restart or change the containers it watches.
Where it’s at
Blackbox has been deployed and is already collecting real logs from my server. The collector, searchable API, and command-line tools are in place, including commands for checking collection health and investigating gaps.
The first round of work has mostly been about making collection dependable and making the stored information useful when something breaks.
Eventually, I want Vista, a dashboard I’m planning for my server, to provide a more convenient way to explore the same logs. For now, Blackbox works on its own, and the CLI is how I use it.
Changelog
0.0.2latest5 new · 2 fixes · 5 changes
added
- Vista can use the API, with its own token in
SHARED_BLACKBOX_VISTA_TOKENand the same read access as the CLI. GET /v1/stats/errorscounts error and warning lines per project, per hour or day, with each project’s totals.GET /v1/stats/errors/groupsgroups repeated lines by project, service, level and fingerprint: the message and itserrfield, with ids and numbers taken out. Each group has a count, when it was first and last seen, and its newest line, forcontext. Both endpoints cover the last 24 hours unless given a range, and at most 31 days.- The CLI’s
errorscommand lists the repeated errors, most frequent first;--level warnadds warnings. - An MIT
LICENSE.
changed
blackbox-apineeds a token for every consumer to start, now includingSHARED_BLACKBOX_VISTA_TOKEN.- The image runs as user 10001; only
blackbox-proxyruns as root, set in the compose file, to read the Docker socket. - Blackbox’s start line no longer repeats its version and environment, which are read from Docker.
- Go 1.27.4.
- The README is rewritten, with the features, the API and every setting.
fixed
- A service that stops on an error logs why at
ERROR, instead of as plain text with no level, so searches and error counts include it. - A shutdown that runs past its time limit is logged instead of ignored.
0.0.12 fixes · 1 change
changed
- The API moved to port 3190 (
blackbox-api:3190onspark), and to 3191 for local development. It stays unpublished in prod.
fixed
- Ordinary sentences about cookies are no longer hidden: chat lines such as “Your daily cookie: …” were redacted as if they were
Cookie:headers. Real cookie headers andcookie=values still are. - Tabs in log lines show as spaces in the CLI, not
?. Multi-line Postgres statements are readable now.
0.0.010 new
added
blackbox-proxy: the only part with the Docker socket. It has no network, lists containers without their environment or mounts, and passes log bytes through without reading them.blackbox-collector: follows every container, running or stopped, unless it’s labelledcom.mobasity.logs=off. Each line’s project, service and version come from Docker’s labels.- Lines are parsed from JSON,
slogtext, Go’slog, cloudflared and Postgres. Anything else is kept as plain text with levelunknown. - Secrets in lines are hidden: bearer tokens, passwords in URLs,
AuthorizationandCookievalues, and values under sensitive names. - Each batch of lines is saved in one transaction with its containers’ checkpoints, so a restart or an outage loses nothing and repeats nothing.
- Known and possible loss is recorded as a gap: a container removed before it was read, the collector being down, or a Docker log damaged by a power cut.
- Retention of 30 days, with a 1 GB cap that removes the oldest records first.
blackbox-api: authenticated search, single records, surrounding lines, sources, gaps and status, onblackbox-api:2600.- The CLI:
search,show,context,status,sources,gaps,consumers,migrate status,version,help. - Blackbox’s own logs follow Spark’s logging standard, through
blackboxlog.
More to look at
all projects-
I push code to GitHub, and my server takes it from there.
-
My own little vault for the passwords, keys, and secrets my projects need.
-
One consistent way for my Go projects to communicate with Cove.