Docker Container Logs

Collect the container logs in your Docker environment to troubleshoot issues with the applications running on it. Site24x7 provides easy access to collect your logs directly via the AppLog agent running on your Linux server. Learn more about log management with Site24x7.

Getting started 

  1. Log in to your Site24x7 account.
  2. Download and install the Site24x7 Server Monitoring agent (Linux). 
  3. Go to Admin > AppLogs > Log Profile and Add Log Profile.

If you do not have an agent installed in the host, but in the docker container, please use the command given below to install the Docker agent:

docker run -d --name site24x7-agent -v /var/run/docker.sock:/var/run/docker.sock:ro -v /proc/:/host/proc/:ro -v /sys:/host/sys/:ro -v /var/lib/docker/containers/:/var/lib/docker/containers/:ro -e KEY= < Your Device Key > site24x7/docker-agent:release1759

Replace <Your Device Key> with the key found on the Device Key page (accessed via Admin > Developer > Device Key).

Log file path

Each application writes logs in different folders and files. By default, container logs will be sourced from the below-mentioned folder path. If you have logs in a different folder, you can mention it under the File Path to source them from that particular folder while creating a log profile.

:
/var/lib/docker/containers/**/*-json.log

Log pattern

json $log$ $stream$ $time:date:yyyy-MM-dd'T'HH:mm:ss.SSS'Z'$ $ContainerId:config:@folder$

This is the default log pattern defined by Site24x7 for parsing Docker Container logs based on the sample mentioned below.

Sample log

{\"log\":\"Starting image\",\"stream\":\"stdout\",\"time\":\"2019-06-04T11:29:54.295671087Z\"}

The above sample log can be separated into 4 fields, each of which will take its respective value from the original log, and then be uploaded to Site24x7.

Field name Filed value
Log Starting image
Stream stdout
Time 2019-06-04T11:29:54
Container ID 295671087Z

Docker Container logs dashboard

AppLogs creates an exclusive dashboard for every Log Type, and shows a few widgets by default. Here's a list of the widgets available in the Docker Container logs dashboard:

  • Container Stats
  • Logs Trend

Docker Container logs dashboard

In addition to the default widgets, your saved searches will also be added to the dashboard automatically.

Related log types

Was this document helpful?
Thanks for taking the time to share your feedback. We’ll use your feedback to improve our online help resources.