Why does CPU goes beyond 600 while using cadvisor

0 votes
docker-compose.yml

version: '3.7'
services:
  cadvisor:
    image: google/cadvisor
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:rw
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
      - /cgroup:/sys/fs/cgroup:ro
    ports:
      - 8080:8080
    privileged: true
    command:
      - --allow_dynamic_housekeeping=true
      - --housekeeping_interval=30s
      - --global_housekeeping_interval=2m
      - --disable_metrics=disk,tcp,udp
      - --docker_only=true
    restart: always
    deploy:
      mode: global

I have disabled most of the flags.I run it with privileged mode yet I see spikes in CPU.How do I make it consume less CPU?

I get the following error too

W0505 06:22:01.988235       1 raw.go:87] Error while processing event ("/sys/fs/cgroup/blkio/system.slice/systemd-tmpfiles-clean.service": 0x40000100 == IN_CREATE|IN_ISDIR): inotify_add_watch /sys/fs/cgroup/blkio/system.slice/systemd-tmpfiles-clean.service: no such file or directory
May 5, 2020 in DevOps & Agile by Isabel
• 120 points
3,717 views
Sure , let me try, thanks
Hi,

Giving the cpus limit it not working, my container does not start when i give cpu limit.

`failed to create service monitor_cadvisor: Error response from daemon: rpc error: code = InvalidArgument desc = invalid cpu value 0.0001: Must be at least 0.001`

Even after i made both the limits for cpu to 0.001 my container does not start. Can you please help with this?
Hi,

Don't give fraction value. At least give 1 or 2 CPUs. If you get an error, then paste your complete code here.
Below is my code:

cadvisor:
    image: gcr.io/google-containers/cadvisor:latest
    networks:
      - monitor
    command: ["-logtostderr", "-v=4", "-docker_only", "-storage_duration=2m0s"]
    privileged: true
    devices:
      - /dev/kmsg
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /:/rootfs:ro
      - /var/run:/var/run
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
      - /dev/disk:/dev/disk:ro
      - /sys/fs/cgroup:/cgroup:ro
    deploy:
      mode: global
      resources:
        limits:
          cpus: '0.001'
          memory: 128M
        reservations:
          cpus: '0.001'
          memory: 64M

Hi,

I tried with the below code. It is working totally fine.

version: '3.2'
services:
   cadvisor:
    image: google/cadvisor:latest
    container_name: cadvi
    ports:
    - 8080:8080
    volumes:
    - /:/rootfs:ro
    - /var/run:/var/run:rw
    - /sys:/sys:ro
    - /var/lib/docker/:/var/lib/docker:ro
    deploy:
        mode: global
        resources:
          limits:
            cpus: '0.01'
            memory: 128M
          reservations:
            cpus: '0.001'
            memory: 64M

In your code, you have set limits for CPUs and reservations for CPUs the same. That is why you got an error. Set the below values and try once.

 limits:
            cpus: '0.01'
            memory: 128M
          reservations:
            cpus: '0.001'
            memory: 64M

1 answer to this question.

0 votes

Hi@Isabel,

I don't know about container advisor tool, but I used this below code and it works fine in my system.

  • First create one folder.
  • Inside that folder create one file name prometheus.yml file and write down the below code.
scrape_configs:
- job_name: cadvisor
  scrape_interval: 5s
  static_configs:
  - targets:
    - cadvisor:8080
  • Inside that same folder create another file name docker-compose.yml and write down the below code.

version: '3.2'
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
    - 9090:9090
    command:
    - --config.file=/etc/prometheus/prometheus.yml
    volumes:
    - ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
    depends_on:
    - cadvisor
  cadvisor:
    image: google/cadvisor:latest
    container_name: cadvisor
    ports:
    - 8080:8080
    volumes:
    - /:/rootfs:ro
    - /var/run:/var/run:rw
    - /sys:/sys:ro
    - /var/lib/docker/:/var/lib/docker:ro
    depends_on:
    - redis
  redis:
    image: redis:latest
    container_name: redis
    ports:
    - 6379:6379
  • Now run docker-compose up and browse http://localhost:8080.

answered May 5, 2020 by MD
• 95,440 points
My cadvisor is up and running.I only have concern with CPU usage.I'm monitoring around 2k containers.
Set threshold value of RAM and CPU to your container.

Related Questions In DevOps & Agile

0 votes
1 answer

Why does Docker for Windows make you pick either Windows or Linux containers?

Windows machine contains several components and one ...READ MORE

answered Nov 15, 2018 in DevOps & Agile by Sophie may
• 10,610 points
546 views
0 votes
1 answer
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
1,183 views
+2 votes
2 answers

how to set different provisioning profiles for different targets using Xcode Build

For multiple targets, each task has to ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by ajs3033
• 7,300 points

edited Oct 16, 2018 by Kalgi 4,310 views
+5 votes
2 answers

Bootstrap SPAapp using Heroku commands

I've made a few assumptions You want to ...READ MORE

answered Oct 16, 2018 in DevOps & Agile by Kalgi
• 52,360 points
685 views
+6 votes
5 answers

can't remove SSIS variables using remove method on PowerShell

you're missing the additional $environment.Alter() after your ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by ajs3033
• 7,300 points
1,958 views
+5 votes
3 answers

Error while trying to install postgis extension with greenplum

Try re downloading the package and installing ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
938 views
+3 votes
1 answer

Unable to find the TargetArguments path While configuring dot cover in VSTS

For your unable to find the TargetArguments ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by ajs3033
• 7,300 points
868 views
0 votes
1 answer

Permission denied when executing module using ansible on host machine

Hi@Shamsher, This error usually occurs when their is ...READ MORE

answered May 29, 2020 in DevOps & Agile by MD
• 95,440 points
3,645 views
0 votes
1 answer

getting error while trying for "kubectl get nodes" on node

Hi@Surya, I think you did not configure your ...READ MORE

answered Jul 9, 2020 in DevOps & Agile by MD
• 95,440 points
1,665 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP