Re: Question about LTTng Context
Amir Najafi Zadeh via lttng-dev <[email protected]> Thu, 11 Dec 2025 10:51:50 -0500
| Newsgroups | org.lttng.lists.lttng-dev |
|---|---|
| Message-ID | <CAOQX81e-dtfgLQ+xTt8kr-Qxc+hhiaW4vHF=S=RDVsMR0-TnLA@mail.gmail.com> |
--0000000000004025e40645af20ad Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Michael, Kienan, Thank you both for your replies. As you mentioned the cgroup namespace, it isn=E2=80=99t very helpful in some cases. Containers m= ay share the same cgroup namespace, and the container runtime often avoids giving each container a private cgroup namespace for performance and security reasons. Because of this, the cgroup namespace can=E2=80=99t be used as a r= eliable or unique label for filtering trace logs. In my case, with container-d you can inspect a container, find its PID, and then check /proc/<pid>/ns/cgroup, but you=E2=80=99ll see that different con= tainers often have the same cgroup namespace ID (e.g., in the following logs you can see the calico-node and kube-proxy containers sharing a cgroup ns). ``` Name: calico-node CID: b5624afe31b005725f4ba53c7b6fe758f3c09fabf013085231ff8b97588f6ace PID: 2243 cgroup_ns_inode: 4026531835 Name: kube-proxy CID: 52f3c12def7a680f61a925ac92dd5ebd5eba6cad17d671efbfd1d40db7dff624 PID: 1851 cgroup_ns_inode: 4026531835 >> MATCH FOUND: shares ns with container: b5624afe31b005725f4ba53c7b6fe758f3c09fabf013085231ff8b97588f6ace (calico-node) ``` Thanks again for your answers. I hope this feature appears in a future patch. Best, Amir On Thu, Dec 11, 2025 at 9:57=E2=80=AFAM Michael Jeanson <mjeanson@efficios.= com> wrote: > On 12/11/25 09:30, Kienan Stewart via lttng-dev wrote: > > Hi Amir, > > > > On 12/10/25 9:40 PM, Amir Najafi Zadeh via lttng-dev wrote: > >> Hello everyone, > >> > >> I hope you=E2=80=99re doing well. My name is Amir, and I=E2=80=99m a P= hD student in > >> the Computer Science department at Stony Brook University, New York. > >> > >> I have a question about the LTTng context that I haven=E2=80=99t been = able to > >> find an answer for in the docs or man pages. Does LTTng support adding > >> the cgroup ID or cgroup path as a context field? I want to filter my > >> trace results based on cgroups. > >> > > > > I think you're looking for the `cgroup_ns` context which adds the inum > > of the cgroup namespace as a context field. > > This will give you the ID of the cgroup namespace but we don't have > contexts for cgroups themselves. It's probably something we would like > to have but there is no concrete plans on implementing this at the moment= . > > > > >> If this isn=E2=80=99t supported, are there any plans to add it in futu= re > >> versions, such as 2.14? > >> > >> For reference, I=E2=80=99m currently using LTTng 2.13 on Ubuntu 24.04 = with > >> kernel 6.8.0-87-generic. > >> > >> Cheers, > >> Amir > >> -- > >> *Amirhossein Najafizadeh* > >> *PhD Student, Computer Science Department, Stony Brook University, N.Y= . > >> File systems and Storage Lab (FSL) > --0000000000004025e40645af20ad Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Michael, Kienan, Thank you both for your replies. As you m= entioned the cgroup namespace, it isn=E2=80=99t very helpful in some cases.= Containers may share the same cgroup namespace, and the container runtime = often avoids giving each container a private cgroup namespace for performan= ce and security reasons. Because of this, the cgroup namespace can=E2=80=99= t be used as a reliable or unique label for filtering trace logs.<br><br>In= my case, with container-d you can inspect a container, find its PID, and t= hen check /proc/<pid>/ns/cgroup, but you=E2=80=99ll see that differen= t containers often have the same cgroup namespace ID (e.g., in the followin= g logs you can see the calico-node and kube-proxy containers sharing a cgro= up ns).<br><br>```<br>Name: calico-node =C2=A0CID: b5624afe31b005725f4ba53c= 7b6fe758f3c09fabf013085231ff8b97588f6ace =C2=A0PID: 2243 =C2=A0cgroup_ns_in= ode: 4026531835<br>Name: kube-proxy =C2=A0CID: 52f3c12def7a680f61a925ac92dd= 5ebd5eba6cad17d671efbfd1d40db7dff624 =C2=A0PID: 1851 =C2=A0cgroup_ns_inode:= 4026531835<br>=C2=A0 >> MATCH FOUND: shares ns with container: b5624= afe31b005725f4ba53c7b6fe758f3c09fabf013085231ff8b97588f6ace (calico-node)<b= r>```<br><br>Thanks again for your answers. I hope this feature appears in = a future patch.<br><br>Best,<br>Amir</div><br><div class=3D"gmail_quote gma= il_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Thu, Dec 11, 2= 025 at 9:57=E2=80=AFAM Michael Jeanson <<a href=3D"mailto:mjeanson@effic= ios.com">[email protected]</a>> wrote:<br></div><blockquote class=3D= "gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2= 04,204,204);padding-left:1ex">On 12/11/25 09:30, Kienan Stewart via lttng-d= ev wrote:<br> > Hi Amir,<br> > <br> > On 12/10/25 9:40 PM, Amir Najafi Zadeh via lttng-dev wrote:<br> >> Hello everyone,<br> >><br> >> I hope you=E2=80=99re doing well. My name is Amir, and I=E2=80=99m= a PhD student in <br> >> the Computer Science department at Stony Brook University, New Yor= k.<br> >><br> >> I have a question about the LTTng context that I haven=E2=80=99t b= een able to <br> >> find an answer for in the docs or man pages. Does LTTng support ad= ding <br> >> the cgroup ID or cgroup path as a context field? I want to filter = my <br> >> trace results based on cgroups.<br> >><br> > <br> > I think you're looking for the `cgroup_ns` context which adds the = inum <br> > of the cgroup namespace as a context field.<br> <br> This will give you the ID of the cgroup namespace but we don't have <br= > contexts for cgroups themselves. It's probably something we would like = <br> to have but there is no concrete plans on implementing this at the moment.<= br> <br> > <br> >> If this isn=E2=80=99t supported, are there any plans to add it in = future <br> >> versions, such as 2.14?<br> >><br> >> For reference, I=E2=80=99m currently using LTTng 2.13 on Ubuntu 24= .04 with <br> >> kernel 6.8.0-87-generic.<br> >><br> >> Cheers,<br> >> Amir<br> >> -- <br> >> *Amirhossein Najafizadeh*<br> >> *PhD Student, Computer Science Department, Stony Brook University,= N.Y.<br> >> File systems and Storage Lab (FSL)<br> </blockquote></div> --0000000000004025e40645af20ad--