d3vilh/cadvisor

By d3vilh

Updated 9 months ago

Latest official cAdvisor image for AMD64, ARM64v8, ARM32v7 and ARM32v5.

Image
Integration & Delivery
Message Queues
Monitoring & Observability
0

2.6K

cAdvisor

cAdvisor (Container Advisor). Version 0.49.1 from official repo.

Build for AMD64, ARM64v8, ARM32v7, ARM32v5 and tested on x86_64 AMD and RaspberryPi computers.

It provides container users an understanding of the resource usage and performance characteristics of their running containers. It is a running daemon that collects, aggregates, processes, and exports information about running containers. Specifically, for each container it keeps resource isolation parameters, historical resource usage, histograms of complete historical resource usage and network statistics. This data is exported by container and machine-wide.

cAdvisor has native support for Docker containers and should support just about any other container type out of the box. We strive for support across the board so feel free to open an issue if that is not the case. cAdvisor's container abstraction is based on lmctfy's so containers are inherently nested hierarchically.

Quick Start: Running cAdvisor in a Docker Container

To quickly tryout cAdvisor on your machine with Docker, we have a Docker image that includes everything you need to get started. You can run a single cAdvisor to monitor the whole machine. Simply run this Docker compose:

---
version: "3.1"

networks:
  back-tier:

services:
  cadvisor:
    container_name: cadvisor
    image: d3vilh/cadvisor:latest
    restart: unless-stopped
    privileged: true
    command:
      - '--raw_cgroup_prefix_whitelist=/docker/'
      - '--docker_only=true'
      - '--disable_metrics=memory_numa,advtcp,cpuset,referenced_memory,cpu_topology,tcp,udp,percpu,process,hugetlb,sched'
      - '--housekeeping_interval=30s'
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:ro
      - /sys/fs/cgroup:/cgroup:ro
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro
      - /etc/machine-id:/etc/machine-id:ro
    devices:
      - '/dev/kmsg:/dev/kmsg'
    ports:
      - '8081:8080/tcp'
    networks:
      - back-tier

cAdvisor is now running (in the background) on http://localhost:8080. The setup includes directories with Docker state cAdvisor needs to observe.

Example visualisation in Grafana

IMAGE1IMAGE2

You can run it with following Prometheus setup, as example:

services:
  prometheus:
    container_name: prometheus
    image: prom/prometheus:latest
    restart: always
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.path=/prometheus'
      - '--storage.tsdb.retention.time=90'
      - '--web.console.libraries=/usr/share/prometheus/console_libraries'
      - '--web.console.templates=/usr/share/prometheus/consoles'
    volumes:
      - ./prometheus/:/etc/prometheus/
      - prometheus_data:/prometheus
    ports:
      - 9090:9090
    links:
      - ping:ping
      - speedtest:speedtest
    networks:
      - back-tier

Prometheus config

Build method

Following Dockerfile used to build image:

FROM golang:buster AS builder
ARG VERSION
RUN apt-get update \
 && apt-get install make git bash gcc \
 && mkdir -p $GOPATH/src/github.com/google \
 && git clone https://github.com/google/cadvisor.git $GOPATH/src/github.com/google/cadvisor
WORKDIR $GOPATH/src/github.com/google/cadvisor
RUN git fetch --tags 
RUN git checkout $VERSION 
RUN go env -w GO111MODULE=auto
RUN make build
RUN cp ./_output/cadvisor /
# ------------------------------------------
# Copied over from deploy/Dockerfile except that the "zfs" dependency has been removed
# a its not available fro Alpine on ARM
FROM alpine:latest
MAINTAINER dengnan@google.com vmarmol@google.com vishnuk@google.com jimmidyson@gmail.com stclair@google.com
LABEL maintainer="Mr.Philipp <d3vilh@github.com>"
RUN sed -i 's,https://dl-cdn.alpinelinux.org,http://dl-4.alpinelinux.org,g' /etc/apk/repositories
RUN apk --no-cache add libc6-compat device-mapper findutils thin-provisioning-tools && \
    echo 'hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4' >> /etc/nsswitch.conf && \
    rm -rf /var/cache/apk/*
# Grab cadvisor from the staging directory.
COPY --from=builder /cadvisor /usr/bin/cadvisor
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --quiet --tries=1 --spider http://localhost:8080/healthz || exit 1
ENTRYPOINT ["/usr/bin/cadvisor", "-logtostderr"]

Here is how you can build it:

docker build --progress=plain  -t local/cadvisor .

Buy Me A Coffee

Docker Pull Command

docker pull d3vilh/cadvisor