Docker logs viewer UI

Logdy.dev
3 min readMar 20, 2024

--

In this blog post, you will learn how to browse docker logs in a Logdy UI. First let’s do a quick recap on Docker logs.

Docker logs recap

Basic command that will display all of the logs.

$ docker logs [CONTAINER_ID or CONTAINER_NAME]

This command will display all logs up until 3 seconds ago

$ docker logs my-container --follow --since=3s

This command will display last 10 lines and will start following new lines added. This command is most similar to tail -f command.

$ docker logs my-container --follow --tail=10

Logs are also stored in files. If you would like to search a big amount of logs, than operating on files might be more handy.

/var/lib/docker/containers/<container_id>/<container_id>-json.log

Alternative Docker logs browser UI

Logdy is an alternative to Dozzle, however Logdy can do much more, it’s extensible, and can parse and adapt to any format of logs being produced. In addition you can monitor multiple Docker containers in a single view.

Logdy is also an alternative to hosted solutions like DataDog, Papertrail or Portainer, to name a few.

Setup logs browser for Docker with Logdy

The basic version of listening to logs from a single Docker container

$ docker logs my-container --follow --tail=10 | logdy

A setup that allows to listen and combine logs from multiple containers into a single stream.

$ logdy socket 8123 8124
$ docker logs my-container1 --follow --tail=10 | logdy forward 8123
$ docker logs my-container2 --follow --tail=10 | logdy forward 8124

TIP

You can forward logs to a single port if you don’t need an information from which container a specific log line is coming from. The above setup let’s you see from which port a specific log line is coming from, so by assigning a container to each port, you can detect the container and display it’s name in the UI.

Enter Logdy web UI

Visit the address provided in the console output after starting Logdy, by default it should be http://localhost:8080

Display columns and filters

Logdy makes parsing and column selection a breeze. Use a built in “autogenerate” feature to generate columns based on JSON object present. Then you can make any adjustments and customizations. Based on the columns you can also emit facets or use another great feature to generate those automatically.

With a JSON object in place, you can use Auto-generated columns together with Faceted columns.

Build mapping for multiple containers

(line: Message): CellHandler => {

let mapping = {
'8123': "mycontainer1",
'8124': "mycontainer2",
}

return {
text: mapping[line.origin.port],
facets: [
{ name: "Container", value: mapping[line.origin.port] }
]
}
}

Meet Logdy

Logdy is a versatile DevOps tool designed to enhance productivity in the terminal. Operating under the UNIX philosophy, Logdy is a single-binary tool that requires no installations, deployments, or compilations. It works locally, ensuring security, and can be seamlessly integrated into the PATH alongside other familiar commands like grep, awk, sed, and jq. It is particularly beneficial for professionals such as software engineers, game developers, site reliability engineers, sys admins, and data scientists who frequently work with terminal logs or outputs.

Logdy records the output of processes, whether from standard output or a file and directs it to a web UI. The web UI served on a specific port by Logdy, provides a reactive, low-latency application for browsing and searching through logs. It supports various use cases, such as tailing log files, integrating with applications (e.g., node.js, Python scripts, Go programs, or anything else that produces standard output), and tools like kubectl, docker logs etc.

One notable feature is its hackability with TypeScript, allowing users to filter, parse, and transform log messages by writing TypeScript code directly within the browser. This hackability provides flexibility to express custom logic without delving into the intricacies of other command-line tools. Overall, Logdy offers a convenient and efficient solution for managing and analyzing terminal logs.

--

--

Logdy.dev

Supercharge your terminal logs with a UI and low-code