Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To use perf record to monitor each individual docker container through cgroup, follow these steps:

  1. Install perf on the host machine if it is not already installed.

  2. Make sure cgroups are enabled and properly set up on the host. Verify that your containers are running inside cgroups.

  3. Use the following command to start profiling a specific cgroup:

    perf record -C <cgroup_name> -a -g -- sleep <duration_seconds>
    

    Replace <cgroup_name> with the name of the cgroup you want to profile, and <duration_seconds> with the length of time you want to run the profiling.

  4. You can also profile all cgroups associated with a specific docker container using the following command:

    perf record -e <event_name> -G <container_id> -a -- sleep <duration_seconds>
    

    Replace <event_name> with the performance event(s) you want to profile and <container_id> with the ID of the docker container you want to monitor.

  5. Once the profiling is complete, use the following command to generate a report of the collected data:

    perf report
    

    This will give you a detailed breakdown of the performance data collected for the specified cgroup(s) or docker container(s).

Note: Make sure that you have the proper permissions to use perf record on the host machine. You may need to run the command with root privileges or grant permissions to the user running the command.