Last updated at Fri, 03 Nov 2017 19:20:20 GMT

Logentries offers a variety of ways to get logs out of your containerized environment, including our Linux Agent, application plugin libraries, and Syslog. In this post we’ll cover collecting and forwarding logs via our Docker Logentries Container, which requires Docker 1.5 or higher.

To configure the Docker Logentries Container you’ll need to do the following:

  • Create a destination log in your Logentries account to record your Docker logs.
  • Clone the Docker Logentries repository to your container host(s) and build the logging container.
  • Run the Docker Logentries Container.

First, you’ll need to sign-up for a free Logentries trial if you don’t already have an account.

Next, create a token-based log using the instructions available in our documentation. Copy the log token associated with your newly created log and keep it somewhere handy; you’ll need it to configure the Docker Logentries Container.

Now you’ll need to clone the Docker Logentries repository to your server or instance and build the logging container by running the following as separate commands in your terminal:

git clone https://github.com/nearform/docker-logentries.git
cd docker-logentries
sudo docker build -t docker-logentries .

Lastly, run the container in the background using the log token you obtained earlier:

sudo docker run -d -v /var/run/docker.sock:/var/run/docker.sock logentries/docker-logentries -t <YOUR_LOG_TOKEN> -j

You can pass the -j switch if you log in JSON format, like Bunyan. You can also pass the --no-stats flag if you do not want container statistics to be forwarded to Logentries. The -a or --add flag allows adding fixed values to log messages before they are sent to Logentries. These values are added to your log messages in an easily searchable key value pair format, i.e. “name=value”.

That’s it! Once you run the Docker Logentries Container it will immediately begin collecting logs from existing containers, and will automatically collect logs from new containers as soon as they’re created.

The Docker Logentries Container pulls statistics from the Docker Remote API, and provides metrics relating to network, memory, and CPU utilization. The logging container will also forward all other logs sent to STDOUT from your containers.

By installing the Docker Community Pack in your Logentries account, you can quickly set up dashboards, tags, alerts and saved queries to ensure you’re getting the most out of your container metrics.