Live Elasticsearch Online Training starting on Oct 10! See all classes

Solution Deployment: Monitoring and Logging for Docker Datacenter

Solution Deployment

The deployment of Sematext Docker Agent requires three steps:



Connect docker-compose client to Docker UCP

Download client bundle from Docker UCP user profile. Set the environment for the docker CLI with the certificates and scripts included in the client bundle.


Create SPM & Logsene for Sematext Docker Agent

  1. Obtain SPM and Logsene App Tokens from Sematext
  2. Set container constraints with a negative affinity to the container name to ensure that Sematext Docker Agent runs only once on each node


Deploy Sematext Docker Agent

Deploy the monitoring agent to all cluster nodes as global service

As soon the agent is deployed it ships metrics, events and logs collected via the local Docker Remote API endpoint (e.g. /var/run/docker.sock) to the configured backend. In this example we don’t configure specific SPM and Logsene servers, and rely on the default values for SaaS.

8.1 Connect Docker-Compose to Docker UCP Cluster

After installing UCP, you can run the docker command against UCP cluster nodes. Since all traffic between users and UCP nodes is secure and authenticated, when using the Docker CLI client, you’ll need to provide client certificates.

Download the bundle that contains the client certificates for a user from the UCP web app:

  1. If you haven’t already done so, log into UCP
  2. Navigate to your profile
  3. As an example, if you’re logged in as the Admin user, on the right-hand menu, navigate to Admin > Profile
  4. Click the Create Client Bundle button
  5. The browser downloads the file
  6. Copy the client bundle in your working directory and extract the files

$ cp ~/Downloads/ .

$ unzip

  1. Run the included shell script to set the environment variables to access UCP with docker CLI client

         $ source

  1. Check the settings by running “docker info” to see if docker CLI is connected to UCP

$ docker info

8.2 Configure Sematext Docker Agent for Docker UCP

Sematext Docker Agent is configured via environment variables. Appendix A lists all configuration options (e.g. filter for specific images and containers), but we’ll keep it simple here.

8.2.1 Create SPM and Logsene Apps

  1. Sign up for free at, if you haven’t done that already
  2. Create an SPM App of type “Docker” to obtain the SPM App Token. SPM App will hold your Docker UCP performance metrics.

Docker UCP Monitoring

  1. Create a Logsene App to obtain the Logsene Token. Logsene App will hold your Docker UCP logs.

Docker UCP Logs

8.2.2 Deploy the Agent to all Docker UCP Nodes

To deploy Sematext Docker Agent to all nodes, we have to run a global Swarm service, including the Logsene and SPM application tokens, and access to the local docker socket on each node:

docker service create –mode global –name sematext-agent-docker \

–mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \




If you have to use a proxy add -e HTTPS_PROXY=https://your-proxy-server:port to the service command above.

The command outputs the Docker Swarm service ID, which could be used with the docker service command.  If you check the status of the service with docker service ps SERVICE_ID you’ll see sematext-docker-agent getting scheduled for deployment on each node shortly after running the above command.

Note: The global services ensures that Sematext Docker Agents gets deployed to each node and every new node added to Docker UCP.

   Sematext Docker Agent running on all Docker UCP nodes

Sematext Docker Agent running on all Docker UCP nodes

8.2.3 Voila!  Your Docker Monitoring & Logging Works

After about a minute you should see the performance metrics of all Docker UCP nodes and deployed containers in your SPM Apps…

Key Docker metrics in SPM

Key Docker metrics in SPM

The Server view should show all Docker UCP nodes:

Docker UCP nodes

Docker UCP nodes

…and you will see all your Docker logs in Logsene.

This screenshot shows parsed web server logs tagged with Docker compose metadata, such as compose project, server, container number:

Logsene native UI shows automatically parsed log structure

Logsene native UI shows automatically parsed log structure

Logsene integrated Kibana dashboards to slice and dice Docker log data

Logsene integrated Kibana dashboards to slice and dice Docker log data

8.2.4 Connect Metrics and Logs for Faster Troubleshooting

For faster troubleshooting you can connect apps (SPM app with SPM app, Logsene with Logsene, or SPM with Logsene).  Connecting apps lets you more easily correlate metrics and logs and thus more quickly find the root cause of performance and other issues.

  1. Open “Logs” section in SPM, click to the link icon in the top right corner and choose your Logsene Application.
  2. Press the connect button to save the setting

Once SPM app with your Docker metrics and events and your Logsene app with your Docker logs are connected, you can see all these data in a single pane of glass:

Docker performance metrics and logs in a single pane of glass

Docker performance metrics and logs in a single pane of glass

For more information visit Sematext Docker Agent page.