I want to use the perf to monitor the docker container with:
$sudo perf stat -e cycles -a -I 1000 -o out.txt --cgroup=docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95 sleep 5
however, it can not count the cycles in out.txt:
1 # started on Thu Jun 7 22:49:34 2018
2
3 # time counts unit events
4 1.000224074 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
5 2.000515835 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
6 3.000805321 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
7 4.001008437 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
8 5.001234875 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
And monitoring multi-events such as:
$sudo perf stat -e cycles,instructions -a -I 1000 -o out2.txt --cgroup=docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95,docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95 sleep 5
Got the same result in out2.txt:
1 # started on Thu Jun 7 23:23:15 2018
2
3 # time counts unit events
4 1.000326390 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
5 1.000326390 <not counted> instructions docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
6 2.000665181 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
7 2.000665181 <not counted> instructions docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
8 3.000979419 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
9 3.000979419 <not counted> instructions docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
10 4.001281621 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
11 4.001281621 <not counted> instructions docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
12 5.001233401 <not counted> cycles docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
13 5.001233401 <not counted> instructions docker/c04e4686d0195f9863112983e472ec7b519642bf4cfd3856f327d02e05047f95
How to count the cycles for docker container?
I have look at Monitoring Linux performance events for cgroups and kubelet fails to get cgroup stats for docker and kubelet services.