Splunk Completes Acquisition of Plumbr Learn more

Usage in Docker

To use the agent in a Docker container without having the agent installed in the host, the following steps must be taken. Full examples are after that.

Step 1 – installation

Can be performed either during container launch (installer directory mounted to container) or during image building (installer copied during image building and then run). The following command must be run either during building the image or as the first command when running the container: /path/to/plumbr-agent-installer/PlumbrAgentInstaller --unpack-only --cluster-id=example-cluster with your desired cluster name.

Step 2 – launch agent process

The agent process must be launched in the background when launching the process, so it would not block the next command (original entry point). This requires changing the container entry point, which can be done either by putting all the commands (optional installation, agent launch, original entry point with environment variables) in a script file and mounting that, or including all of it in the container start command.

If your image is using a musl-based Docker base image, then the agent process must be launched differently, by prepending /lib/ld-musl-x86_64.so.1 – to the command.

Step 3 – attach

To make the agent libraries get attached to processes in the container, the LD_PRELOAD=/opt/plumbr-agent/libplumbrmonitor.so environment variable must be set. Since the original entry point must be manually invoked anyway due to entry point change, the easiest way to set this is include it in that command.

Full example – install in container, mount launch script

Mount agent installer:
/host/path/to/plumbr-agent-installer to /opt/plumbr-agent-installer as read-only

Mount the following as /launch-with-plumbr.sh:

/opt/plumbr-agent-installer/PlumbrAgentInstaller --unpack-only --cluster-id=[example-cluster] /opt/plumbr-agent/plumbrd &
LD_PRELOAD=/opt/plumbr-agent/libplumbrmonitor.so [original-entry-point] "$@"

Override entry point with /launch-with-plumbr.sh.

Full example – install in container, launch command

Mount agent installer:
/host/path/to/plumbr-agent-installer to /opt/plumbr-agent-installer as read-only

Override entry point with /bin/sh, set command to /opt/plumbr-agent-installer/PlumbrAgentInstaller --unpack-only --cluster-id=[example-cluster] && (/opt/plumbr-agent/plumbrd & LD_PRELOAD=/opt/plumbr-agent/libplumbrmonitor.so [original_entry_point]).

Full example – install in image

Create launch script launch-with-plumbr.sh:

/opt/plumbr-agent/plumbrd &
LD_PRELOAD=/opt/plumbr-agent/libplumbrmonitor.so [original-entry-point] "$@"

Dockerfile change:

COPY /path/to/launch-script.sh /launch-with-plumbr.sh
COPY /path/to/plumbr-agent-installer /opt/plumbr-agent-installer
RUN /opt/plumbr-agent-installer/PlumbrAgentInstaller --unpack-only --cluster-id=[example-cluster] ENTRYPOINT ["/launch-with-plumbr.sh"]