Skip to content

Instantly share code, notes, and snippets.

@ndrpnt
Last active August 2, 2021 20:07
Show Gist options
  • Save ndrpnt/d3af34010059eca1300b18542f49c083 to your computer and use it in GitHub Desktop.
Save ndrpnt/d3af34010059eca1300b18542f49c083 to your computer and use it in GitHub Desktop.
Collect Docker (system) events with any log management stack

Why?

Docker (system) events are only available through the Docker Engine API, e.g. with the Docker client docker events or docker system events commands. Sadly, few log forwarders have a facility to collect these events.

How?

Most log forwarders can natively collect containers' logs. Let's create a container that spits Docker events to stdout.

What?

docker run --volume /var/run/docker.sock:/var/run/docker.sock docker events --format '{{json .}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment