<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I'm re-adding the list so every one can benefit from the exchange.</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
The agent and session daemon both attempt to communicate on "0.0.0.0" (the local host). I would assume you can expose/publish (in docker terms) the session daemon's port on the local interface too. I have not tried that though.</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
As for the contents of the <span style="font-family: Consolas, Courier, monospace;">/var/run/lttng</span> folder, you ultimately have to make those files accessible to the applications. You can use the
<span style="font-family: Consolas, Courier, monospace;">LTTNG_HOME</span> environment variable to control where the session daemon creates those files and where the applications look for them. Then, adjust the container's mount points accordingly.</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
To record the events, the shared memory must be accessible to both ends (host and container). You will need to mount /dev/shm inside the container.</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
I think Michael's configuration for Kubernetes can help you understand how the various parts fit together:</div>
<div class="elementToProof ContentPasted0" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<a href="https://github.com/mjeanson/gcloud-lttng/blob/master/pods/demo1.yaml.in" data-auth="NotApplicable" id="LPNoLPOWALinkPreview">https://github.com/mjeanson/gcloud-lttng/blob/master/pods/demo1.yaml.in</a><br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<br>
<div class="elementToProof ContentPasted0" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Jérémie</div>
<div class="elementToProof">
<div class="elementToProof" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
--</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Jérémie Galarneau</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div>EfficiOS Inc.</div>
<a href="https://www.efficios.com" data-auth="NotApplicable" data-loopstyle="link">https://www.efficios.com</a><br>
</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Adel Belkhiri <adel.belkhiri@gmail.com><br>
<b>Sent:</b> March 16, 2023 19:23<br>
<b>To:</b> Jérémie Galarneau <jgalar@efficios.com><br>
<b>Subject:</b> Re: [lttng-dev] Tracing a docker containerized java application from the host</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hello again,
<div><br>
</div>
<div>I solved the issue. The problem was that the host address from inside the container was 172.0.0.1 but the agent was looking for 127.0.0.1. So, one last question, is it possible to instruct the agent to look for/communicate with the sessiond using a specific
address (different from 127.0.0.1)? Also, I'm currently sharing the folder "/var/run/lttng" with the container, which in my opinion isn't a very elegant way. Then, is it possible to do otherwise? If I only copy the file "agent.port" inside the container, I
can list the registered events, but I cannot record them. (I guess it is related to the location of the app socket file).</div>
<div><br>
</div>
<div>Adel</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Thu, Mar 16, 2023 at 3:57 PM Adel Belkhiri <<a href="mailto:adel.belkhiri@gmail.com" data-auth="NotApplicable" data-loopstyle="link">adel.belkhiri@gmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div dir="ltr">Hi Jérémie,
<div><br>
</div>
<div>Thank you for your reply. Yes, the container can communicate with the LTTtng session daemon that is running on the host machine. For instance, if I execute "lttng list -u" on the host I can see that there is an application registered and there are userspace
events (e.g., lttng_jul:event, statedumps, etc.). However, when I execute "lttng --jul -a", no java events are displayed.</div>
<div><br>
</div>
<div>Adel</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Thu, Mar 16, 2023 at 12:14 PM Jérémie Galarneau <<a href="mailto:jgalar@efficios.com" data-auth="NotApplicable" data-loopstyle="link">jgalar@efficios.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Hi Adel,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
The java tracing facilities make use of an agent that communicates with the session deamon through a TCP socket. You must to ensure your java application can connect to the session daemon's 'agent-tcp-port'.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<a href="https://lttng.org/man/8/lttng-sessiond/v2.13/#doc-opt--agent-tcp-port" data-auth="NotApplicable" id="x_m_-2463321664597418825m_4241169599360089359LPNoLPOWALinkPreview">https://lttng.org/man/8/lttng-sessiond/v2.13/#doc-opt--agent-tcp-port</a><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Is that port properly exposed by your container configuration?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<span style="color:rgb(0,0,0); font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt">Jérémie</span><br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div id="x_m_-2463321664597418825m_4241169599360089359Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
--</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Jérémie Galarneau</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<div>EfficiOS Inc.</div>
<a href="https://www.efficios.com" data-auth="NotApplicable" data-loopstyle="link">https://www.efficios.com</a><br>
</div>
</div>
</div>
</div>
<div id="x_m_-2463321664597418825m_4241169599360089359appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-2463321664597418825m_4241169599360089359divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> lttng-dev <<a href="mailto:lttng-dev-bounces@lists.lttng.org" data-auth="NotApplicable" data-loopstyle="link">lttng-dev-bounces@lists.lttng.org</a>>
on behalf of Adel Belkhiri via lttng-dev <<a href="mailto:lttng-dev@lists.lttng.org" data-auth="NotApplicable" data-loopstyle="link">lttng-dev@lists.lttng.org</a>><br>
<b>Sent:</b> March 15, 2023 20:03<br>
<b>To:</b> <a href="mailto:lttng-dev@lists.lttng.org" data-auth="NotApplicable" data-loopstyle="link">
lttng-dev@lists.lttng.org</a> <<a href="mailto:lttng-dev@lists.lttng.org" data-auth="NotApplicable" data-loopstyle="link">lttng-dev@lists.lttng.org</a>><br>
<b>Subject:</b> [lttng-dev] Tracing a docker containerized java application from the host</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div>Hello everyone,<br>
<br>
I am reaching out to seek assistance in tracing an instrumented Java application running within a Docker container from the host side.<br>
<br>
In my setup, the LTTng session daemon, running on the host side, indicates that application registration has been completed (please refer to the logs). However, when running the command "lttng list --jul," no registered applications are displayed. Although
the application successfully creates the "LttngLogHandler" object and attaches it to the logger, no traces are generated.<br>
<br>
To allow the application to access the lttng socket file, the host's /var/run/lttng directory is shared with the container at launch (using the command "sudo docker run -p 8080:8080 -v /var/run/lttng:/var/run/lttng sample-image"). I am only interested in collecting
userspace Java (--jul) traces.<br>
<br>
I would greatly appreciate any assistance or guidance that you can provide. Thank you for your time.<br>
<br>
Additional details include:<br>
<br>
Ubuntu 22.04<br>
Kernel: 5.15.0-60-generic<br>
LTTng session daemon version: 2.13.2<br>
Docker version 20.10.21, build 20.10.21-0ubuntu1~22.04.2<br>
Regards,</div>
<div>Adel Belkhiri <br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</body>
</html>