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 a docker-compose file for Sematext Docker Agent

Create a docker-compose file with the desired configuration

  1. Access to the local docker socket on the Docker UCP node
  2. Add SPM and Logsene App Tokens from Sematext
  3. 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

Scale the monitoring agent to all cluster nodes with docker-compose connected to the Docker UCP Remote API endpoint

The container constraint makes sure that the agent runs only once on each node, while the “docker-compose scale” command ensures that only one instance is created on each node. 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 Configure docker-compose.yml

  1. Edit the values of LOGSENE_TOKEN and SPM_TOKEN in the docker-compose.yml file as shown below:


image: ‘sematext/sematext-agent-docker:latest’




 – affinity:container!=*sematext-agent*

  restart: always


    – /var/run/docker.sock:/var/run/docker.sock

If you have to use a proxy add HTTPS_PROXY=https://your-proxy-server:port to the environment section in the docker-compose.yml.

8.2.3 Deploy the Agent to all Docker UCP Nodes

To deploy Sematext Docker Agent to all nodes, we have to figure out how many Docker UCP nodes are running. The following command prints the number of nodes:

$ docker info | grep Nodes | awk ‘{ print $2 }’


Next, run the combined command to scale Sematext Docker Agent to all nodes, with the docker-compose project name “monitoring”:

$ docker-compose -p monitoring scale sematext-agent=$(docker info | grep Nodes | awk ‘{ print $2 }’)

Creating and starting 1 … done

Creating and starting 2 … done

Creating and starting 3 … done

Note: Currently, Docker Swarm does not have the ability to automatically deploy a container like the one Sematext Docker Agent runs as, to newly added Docker UCP nodes.  Thus, one would have to manually run the above docker scale command when new nodes are added.

Check the number of running agent with “docker-compose -p monitoring ps” or in the Application section in Docker UCP  

   Sematext Docker Agent running on all Docker UCP nodes

Sematext Docker Agent running on all Docker UCP nodes

8.2.4 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.5 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.