Observability
Logging
FerretDB writes structured logs to the standard error (stderr) stream. The most recent entries are also available via getLog command.
Structured log format is not stable yet; field names and formatting of values might change in minor releases.
FerretDB provides the following log formats:
consoleis a human-readable format with optional colors;textis machine-readable logfmt-like format (powered by Go's 0 );jsonif machine-readable JSON format (powered by Go's 0 ).
There are four logging levels:
erroris used for errors that can't be handled gracefully and typically result in client connection being closed;warnis used for errors that can be handled gracefully and typically result in an error being returned to the client (without closing the connection);infois used for various information messages;debugshould only be used for debugging.
The default level is info, except for debug builds that default to debug.
debug-level messages include complete query and response bodies, full error messages, authentication credentials, and other sensitive information.
Since logs are often retained by the infrastructure (and FerretDB itself makes recent entries available via the getLog command), that poses a security risk. Additionally, writing out a significantly larger number of log messages affects FerretDB performance. For those reasons, the debug level should not be enabled in production environments.
The format and level can be adjusted by configuration flags.
Docker logs
If Docker was launched with our quick local setup with Docker Compose, the following command can be used to fetch the logs.
docker compose logs ferretdb
Otherwise, you can check a list of running Docker containers with docker ps and get logs with docker logs:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
13db4c8800d3 postgres "docker-entrypoint.sā¦" About a minute ago Up 59 seconds 5432/tcp my-postgres
44fe6f4c3527 ghcr.io/ferretdb/ferretdb "/ferretdb" About a minute ago Up 59 seconds 8088/tcp, 27018/tcp, 0.0.0.0:27017->27017/tcp my-ferretdb
$ docker logs my-ferretdb
OpenTelemetry traces
FerretDB can be configured to send OpenTelemetry traces to the specified HTTP/OTLP URL (e.g. http://host:4318/v1/traces). It can be changed with