- 1. Introduction
- 2. What you will Learn
- 3. Understand Key Docker Metrics
- 4. Assumptions
- 5. Requirements
- 6. Prerequisites
- 7. Monitoring & Logging Deployment
- 8. Solution Deployment
- 9. Configuring Sematext Docker Agent
- 10. Summary
- 11. Appendix A
- Previous Page Next Page
More info: Sematext Docker Agent
Download PDF version
-
Contents
Solution Deployment
The deployment of Sematext Docker Agent requires three steps:
1 | 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. |
2 | Create SPM & Logsene for Sematext Docker Agent |
|
3 | 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:
- If you haven’t already done so, log into UCP
- Navigate to your profile
- As an example, if you’re logged in as the Admin user, on the right-hand menu, navigate to Admin > Profile
- Click the Create Client Bundle button
- The browser downloads the ucp-bundle-admin.zip file
- Copy the client bundle in your working directory and extract the files
$ cp ~/Downloads/ucp-bundle-admin.zip .
$ unzip ucp-bundle-admin.zip
- Run the included shell script to set the environment variables to access UCP with docker CLI client
$ source env.sh
- 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
- Sign up for free at apps.sematext.com, if you haven’t done that already
- Create an SPM App of type “Docker” to obtain the SPM App Token. SPM App will hold your Docker UCP performance metrics.
- Create a Logsene App to obtain the Logsene Token. Logsene App will hold your 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 \-e SPM_TOKEN=”REPLACE THIS WITH YOUR SPM TOKEN” \-e LOGSENE_TOKEN=”REPLACE THIS WITH YOUR LOGSENE TOKEN” \ sematext/sematext-agent-docker 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
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
The Server view should show all 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 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.
- Open “Logs” section in SPM, click to the link icon in the top right corner and choose your Logsene Application.
- 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
For more information visit Sematext Docker Agent page.