### Example Release Artifact Output Source: https://github.com/google/cadvisor/blob/master/docs/development/releasing.md This is an example of the output generated after a successful build, showing container image tags and binary checksums. ```text Multi Arch Container: gcr.io/cadvisor/cadvisor:v0.44.1-test-8 Architecture Specific Containers: gcr.io/cadvisor/cadvisor-arm:v0.44.1-test-8 gcr.io/cadvisor/cadvisor-arm64:v0.44.1-test-8 gcr.io/cadvisor/cadvisor-amd64:v0.44.1-test-8 Binaries: SHA256 (cadvisor-v0.44.1-test-8-linux-arm64) = e5e3f9e72208bc6a5ef8b837473f6c12877ace946e6f180bce8d81edadf66767 SHA256 (cadvisor-v0.44.1-test-8-linux-arm) = 7d714e495a4f50d9cc374bd5e6b5c6922ffa40ff1cc7244f2308f7d351c4ccea SHA256 (cadvisor-v0.44.1-test-8-linux-amd64) = ea95c5a6db8eecb47379715c0ca260a8a8d1522971fd3736f80006c7f6cc9466 ``` -------------------------------- ### Example cAdvisor Command with Statsd Source: https://github.com/google/cadvisor/blob/master/docs/storage/statsd.md A complete command-line example to start cAdvisor and send metrics to a Statsd instance. The default Statsd port is 8125. ```bash cadvisor --storage_driver="statsd" --storage_driver_host="localhost:8125" ``` -------------------------------- ### MachineInfo Struct Example Source: https://github.com/google/cadvisor/blob/master/client/v2/README.md An example of the returned MachineInfo struct, showing hardware details like cores, memory, and filesystems. ```go (*v1.MachineInfo)(0xc208022b10) ({ NumCores: (int) 4, MemoryCapacity: (int64) 2106028032, Filesystems: ([]v1.FsInfo) (len=1 cap=4) { (v1.FsInfo) { Device: (string) (len=9) "/dev/sda1", Capacity: (uint64) 19507089408 } } }) ``` -------------------------------- ### Attributes Struct Example Source: https://github.com/google/cadvisor/blob/master/client/v2/README.md An example of the returned Attributes struct, which includes hardware details and software versions like Docker and cAdvisor. ```go (*v2.Attributes)({ KernelVersion: (string) (len=17) "3.13.0-44-generic" ContainerOsVersion: (string) (len=18) "Ubuntu 14.04.1 LTS" DockerVersion: (string) (len=9) "1.5.0-rc4" CadvisorVersion: (string) (len=6) "0.10.1" NumCores: (int) 4, MemoryCapacity: (int64) 2106028032, Filesystems: ([]v2.FsInfo) (len=1 cap=4) { (v2.FsInfo) { Device: (string) (len=9) "/dev/sda1", Capacity: (uint64) 19507089408 } } }) ``` -------------------------------- ### Perf Event Configuration File Example Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md A JSON configuration file structure for defining core and uncore perf events, including custom event types and configurations. This format is used by cAdvisor for perf event setup. ```json { "core": { "events": [ "event_name" ], "custom_events": [ { "type": 18, "config": [ "0x304" ], "name": "event_name" } ] }, "uncore": { "events": [ "event_name" ], "custom_events": [ { "type": 18, "config": [ "0x304" ], "name": "event_name" } ] } } ``` -------------------------------- ### Install and Configure QEMU for Container Checks Source: https://github.com/google/cadvisor/blob/master/docs/development/releasing.md These commands are required to set up QEMU for cross-architecture container emulation, which is necessary for the check_container.sh script. ```bash sudo apt install qemu-user-static docker run --rm --privileged multiarch/qemu-user-static --reset -p yes ``` -------------------------------- ### Generate Daemonset with Example Patches Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Generates the cAdvisor Daemonset manifest with example patches applied. This allows for testing specific configurations or features. ```bash kubectl kustomize deploy/kubernetes/overlays/examples ``` -------------------------------- ### Apply Daemonset with Example Patches Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Applies the cAdvisor Daemonset with example patches to your Kubernetes cluster. This command generates the patched manifest and applies it. ```bash kubectl kustomize deploy/kubernetes/overlays/examples | kubectl apply -f - ``` -------------------------------- ### Uncore Events Configuration Example Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Demonstrates configuring uncore events with specific PMU prefixes and custom event details. This allows for targeted performance monitoring on different PMUs. ```json { "uncore": { "events": [ "uncore_imc/cas_count_read", "uncore_imc_0/cas_count_write", "cas_count_all" ], "custom_events": [ { "config": [ "0x304" ], "name": "uncore_imc_0/cas_count_write" }, { "type": 19, "config": [ "0x304" ], "name": "cas_count_all" } ] } } ``` -------------------------------- ### Initialize cAdvisor Client Source: https://github.com/google/cadvisor/blob/master/client/v2/README.md Instantiate a new cAdvisor client by providing the REST endpoint URL. Replace the example URL with your actual cAdvisor endpoint. ```go client, err := client.NewClient("http://192.168.59.103:8080/") ``` -------------------------------- ### Get Attributes Source: https://github.com/google/cadvisor/blob/master/client/v2/README.md Retrieve detailed hardware and software attributes using the client. This includes kernel and Docker versions. ```go client.Attributes() ``` -------------------------------- ### Download cAdvisor Source Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Use 'go get -d' to download the cAdvisor source code without building it. This is the first step before compiling. ```bash $ go get -d github.com/google/cadvisor ``` -------------------------------- ### Example perf events configuration using event names Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md This JSON configuration specifies performance events for both core and uncore components, using human-readable event names. ```json { "core": { "events": [ "instructions", "instruction_retired" ] }, "uncore": { "events": [ "uncore_imc/cas_count_read" ], "custom_events": [ { "config": [ "0xc04" ], "name": "uncore_imc/cas_count_read" } ] } } ``` -------------------------------- ### Install libpfm4 Development Packages (Debian/Ubuntu) Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Install the libpfm4 library and development headers on Debian-based systems using apt-get. This is required for cAdvisor's perf support. ```bash apt-get install libpfm4 libpfm4-dev ``` -------------------------------- ### Get Version Info Source: https://github.com/google/cadvisor/blob/master/client/v2/README.md Retrieve the cAdvisor version information using the client. ```go client.VersionInfo() ``` -------------------------------- ### Install libpfm4 Development Packages (RHEL/CentOS) Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Install the libpfm4 library and development headers on RHEL-based systems using yum. This is required for cAdvisor's perf support. ```bash yum install libpfm libpfm-devel ``` -------------------------------- ### Build cAdvisor with Perf Support Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Build cAdvisor with support for performance monitoring events by setting the GO_FLAGS environment variable. Ensure 'libpfm4-dev' is installed. ```bash $GOPATH/src/github.com/google/cadvisor $ GO_FLAGS="-tags=libpfm,netgo" make build ``` -------------------------------- ### Example perf events configuration with grouped events Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md This JSON configuration demonstrates grouping of performance events for both core and uncore components, allowing for multiple events to be specified within a single group. ```json { "core": { "events": [ ["instructions", "instruction_retired"] ] }, "uncore": { "events": [ ["uncore_imc_0/unc_m_cas_count:rd", "uncore_imc_0/unc_m_cas_count:wr"], ["uncore_imc_1/unc_m_cas_count:rd", "uncore_imc_1/unc_m_cas_count:wr"] ] } } ``` -------------------------------- ### Get Machine Information Source: https://github.com/google/cadvisor/blob/master/docs/api_v2.md Retrieves hardware and software attributes of the running machine. ```APIDOC ## GET /api/v2.0/machine ### Description Retrieves hardware and software attributes of the running machine. ### Method GET ### Endpoint /api/v2.0/machine ### Response #### Success Response (200) - **MachineInfo** (object) - A JSON object representing the MachineInfo struct, containing hardware and software details. ``` -------------------------------- ### Example perf events configuration with custom events Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md This JSON configuration includes custom event definitions for both core and uncore components, allowing for advanced configuration using specific event types and configurations. ```json { "core": { "events": [ "instructions", "instructions_retired" ], "custom_events": [ { "type": 4, "config": [ "0x5300c0" ], "name": "instructions_retired" } ] }, "uncore": { "events": [ "uncore_imc/cas_count_read" ], "custom_events": [ { "config": [ "0xc04" ], "name": "uncore_imc/cas_count_read" } ] } } ``` -------------------------------- ### Run cAdvisor Standalone Source: https://github.com/google/cadvisor/blob/master/docs/running.md Execute the cAdvisor binary to start the service. This command runs cAdvisor in the foreground, making it accessible at http://localhost:8080/. Root privileges may be required for certain data sources. ```bash $ sudo cadvisor ``` -------------------------------- ### Build cAdvisor with Non-volatile Memory Support Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Build cAdvisor with support for IntelĀ® Optaneā„¢ DC Persistent memory by setting the GO_FLAGS environment variable. Ensure 'libipmctl-devel' is installed. ```bash $GOPATH/src/github.com/google/cadvisor $ GO_FLAGS="-tags=libipmctl,netgo" make build ``` -------------------------------- ### Run VM-based Integration Tests with Kubernetes Node-e2e Framework Source: https://github.com/google/cadvisor/blob/master/docs/development/integration_testing.md Execute cAdvisor integration tests on GCE instances using the Kubernetes node-e2e testing framework. This command creates a VM, builds cAdvisor, runs tests, retrieves logs, and cleans up the test environment. Ensure GCP setup and Kubernetes repository cloning are completed beforehand. ```bash $ make test-e2e-node TEST_SUITE=cadvisor REMOTE=true ``` -------------------------------- ### Get Machine Info Source: https://github.com/google/cadvisor/blob/master/client/v2/README.md Retrieve machine hardware information using the client. This method uses the v1 MachineInfo API. ```go client.MachineInfo() ``` -------------------------------- ### Get Attributes Source: https://github.com/google/cadvisor/blob/master/docs/api_v2.md Provides hardware and software attributes of the running machine, including cAdvisor, kernel, docker, and OS versions. ```APIDOC ## GET /api/v2.0/attributes ### Description Provides hardware and software attributes of the running machine, including cAdvisor, kernel, docker, and OS versions. ### Method GET ### Endpoint /api/v2.0/attributes ### Response #### Success Response (200) - **Attributes** (object) - A JSON object representing the Attributes struct, containing hardware and software details. ``` -------------------------------- ### Run Docker Integration Tests with Custom Configuration Source: https://github.com/google/cadvisor/blob/master/docs/development/integration_testing.md Execute integration tests with specific configurations, such as those relying on third-party C libraries. Source a configuration file from build/config before running the make command. This automatically installs necessary packages, applies build flags, and passes additional parameters to cAdvisor. ```bash source build/config/libpfm4.sh && make docker-test-integration ``` -------------------------------- ### Docker Configuration for Redis Metrics Source: https://github.com/google/cadvisor/blob/master/docs/application_metrics.md This example shows how to configure cAdvisor to collect metrics for a Redis container. It involves adding a JSON configuration file to the container image and setting a Docker label to point to its location. ```dockerfile FROM redis ADD redis_config.json /var/cadvisor/redis_config.json LABEL io.cadvisor.metric.redis="/var/cadvisor/redis_config.json" ``` -------------------------------- ### Get Container Stats Summary Source: https://github.com/google/cadvisor/blob/master/docs/api_v2.md Retrieves a summary of CPU and memory usage statistics for specified containers, including percentiles. ```APIDOC ## GET /api/v2.0/summary/ ### Description Retrieves a summary of CPU and memory usage statistics for specified containers, including percentiles (max, average, 90%ile) for the last minute and hour. Supports filtering by container name or Docker ID, and options for recursive retrieval of subcontainer summaries. ### Method GET ### Endpoint /api/v2.0/summary ### Parameters #### Query Parameters - **type** (string) - Optional - Describes the type of identifier. Supported values are `name` (default) and `docker`. - **recursive** (boolean) - Optional - Specifies if summary stats for subcontainers should also be reported. Default is false. ### Response #### Success Response (200) - **container_summary** (object) - A JSON object containing a map from container name to a list of summary objects (DerivedStats struct). ``` -------------------------------- ### Get Version Information Source: https://github.com/google/cadvisor/blob/master/docs/api_v2.md Retrieves the software version of cAdvisor. ```APIDOC ## GET /api/v2.0/version ### Description Retrieves the software version of cAdvisor. ### Method GET ### Endpoint /api/v2.0/version ### Response #### Success Response (200) - **version** (string) - The software version of cAdvisor. ``` -------------------------------- ### Get Machine Information Source: https://github.com/google/cadvisor/blob/master/docs/api.md Retrieves detailed read-only information about the machine's hardware and topology. ```APIDOC ## GET /api/vX.Y/machine ### Description Retrieves read-only machine information, including CPU cores, memory capacity, network devices, and machine topology. ### Method GET ### Endpoint /api/vX.Y/machine ### Response #### Success Response (200) - **cpucores** (integer) - Number of schedulable logical CPU cores - **memorycapacity** (integer) - Memory capacity in bytes - **cpumaxfrequency** (integer) - Maximum supported CPU frequency in kHz - **filesystems** (array) - Available filesystems with major, minor numbers and capacity in bytes - **networkdevices** (array) - Network devices with MAC addresses, MTU, and speed - **machine_topology** (object) - Machine topology details including nodes, cores, threads, per-node memory, and caches ``` -------------------------------- ### Get Container Information Source: https://github.com/google/cadvisor/blob/master/client/README.md Fetch detailed information for a specific container. The NumStats field in the request controls the number of statistics returned. Returns a ContainerInfo struct. ```go request := v1.ContainerInfoRequest{NumStats: 10} sInfo, err := client.ContainerInfo("/docker/d9d3eb10179e6f93a...", &request) ``` -------------------------------- ### Initialize and Use Go cAdvisor Client Source: https://github.com/google/cadvisor/blob/master/docs/clients.md This snippet shows how to import and initialize the official Go client for cAdvisor. It then demonstrates fetching machine information from the API. ```go import "github.com/google/cadvisor/client" client, err = client.NewClient("http://localhost:8080/") mInfo, err := client.MachineInfo() ``` -------------------------------- ### Build cAdvisor from Source Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Compile the cAdvisor binary from the downloaded source code using the 'make build' command. Ensure your Go environment is set up correctly. ```bash $GOPATH/src/github.com/google/cadvisor $ make build ``` -------------------------------- ### Build cAdvisor Docker Container Source: https://github.com/google/cadvisor/blob/master/docs/deploy.md Run this script to statically build the cAdvisor binary and then create the Docker image. The resulting image is tagged 'google/cadvisor:beta'. ```bash ./deploy/build.sh ``` -------------------------------- ### Configure Machine Information Files and Update Interval Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Specify files to check for boot ID and machine ID, and set the interval for updating machine information. ```bash --boot_id_file="/proc/sys/kernel/random/boot_id" --machine_id_file="/etc/machine-id,/var/lib/dbus/machine-id" --update_machine_info_interval=5m ``` -------------------------------- ### Get Container Spec Source: https://github.com/google/cadvisor/blob/master/docs/api_v2.md Retrieves the resource specification for a given container identifier. Options for type and recursion are available. ```APIDOC ## GET /api/v2.0/spec/ ### Description Retrieves the resource specification for a given container identifier. This endpoint allows for specifying the identifier type and requesting specifications for all subcontainers. ### Method GET ### Endpoint /api/v2.0/spec/ ### Parameters #### Path Parameters - **container identifier** (string) - Required - The identifier for the container. #### Query Parameters - **type** (string) - Optional - The type of the identifier (e.g., 'name', 'id'). - **recursive** (boolean) - Optional - If true, retrieves specs for all subcontainers. ### Response #### Success Response (200) - **specifications** (object) - A map from container name to a list of spec objects. Each spec object is a marshalled JSON of the `ContainerSpec` struct. ``` -------------------------------- ### Get Container Stats Source: https://github.com/google/cadvisor/blob/master/docs/api_v2.md Retrieves detailed statistics for specified containers, with options for identifier type, recursion, and sample count. ```APIDOC ## GET /api/v2.0/stats/ ### Description Retrieves detailed statistics for specified containers. Supports filtering by container name or Docker ID, and options for recursive retrieval of subcontainer stats and the number of samples. ### Method GET ### Endpoint /api/v2.0/stats ### Parameters #### Query Parameters - **type** (string) - Optional - Describes the type of identifier. Supported values are `name` (default) and `docker`. - **recursive** (boolean) - Optional - Specifies if stats for subcontainers should also be reported. Default is false. - **count** (integer) - Optional - Number of stats samples to be reported. Default is 64. ### Response #### Success Response (200) - **container_stats** (object) - A JSON object containing a map from container name to a list of stat objects (ContainerStats struct). ``` -------------------------------- ### Configure Storage Driver Options Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Specify the storage driver and its connection details for pushing data beyond the local cache. ```bash --storage_driver="" --storage_driver_buffer_duration="1m0s" --storage_driver_db="cadvisor" --storage_driver_host="localhost:8086" --storage_driver_password="root" --storage_driver_secure=false --storage_driver_table="stats" --storage_driver_user="root" ``` -------------------------------- ### Verify Release Container Images Source: https://github.com/google/cadvisor/blob/master/docs/development/releasing.md Use the check_container.sh script to verify that the built container images for the release are functional. Pass the Multi Arch Container tag as an argument. ```sh build/check_container.sh gcr.io/tstapler-gke-dev/cadvisor:v0.44.1-test-8 ``` -------------------------------- ### Run cAdvisor with Perf Events Configuration Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Run the cAdvisor binary with performance monitoring events enabled, specifying a configuration file for perf events. This requires the perf support to be built into the binary. ```bash $GOPATH/src/github.com/google/cadvisor $ sudo ./cadvisor -perf_events_config=perf/testing/perf-non-hardware.json ``` -------------------------------- ### Configure HTTP Server Options Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md These flags control the HTTP server's behavior, including authentication, listening IP, and port. ```bash --http_auth_file="" --http_auth_realm="localhost" --http_digest_file="" --http_digest_realm="localhost" --listen_ip="" --port=8080 --url_base_prefix=/ ``` -------------------------------- ### Get Subcontainers Information Source: https://github.com/google/cadvisor/blob/master/client/README.md Recursively retrieve information for a container and all its subcontainers. The NumStats field in the request controls the number of statistics returned. Returns a ContainerInfo struct with the Subcontainers field populated. ```go request := v1.ContainerInfoRequest{NumStats: 10} sInfo, err := client.SubcontainersInfo("/docker", &request) ``` -------------------------------- ### Run cAdvisor with Docker and Perf Support Source: https://github.com/google/cadvisor/blob/master/docs/running.md This command enables cAdvisor to collect performance metrics using the perf_event_open syscall. It requires specific security options and volume mounts for performance data access. ```bash docker run \ --volume=/:/rootfs:ro \ --volume=/var/run:/var/run:ro \ --volume=/sys:/sys:ro \ --volume=/var/lib/docker/:/var/lib/docker:ro \ --volume=/dev/disk/:/dev/disk:ro \ --volume=$GOPATH/src/github.com/google/cadvisor/perf/testing:/etc/configs/perf \ --publish=8080:8080 \ --device=/dev/kmsg \ --security-opt seccomp=default.json \ --name=cadvisor \ ghcr.io/google/cadvisor: -perf_events_config=/etc/configs/perf/perf.json ``` -------------------------------- ### Run Built cAdvisor Binary Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Execute the compiled cAdvisor binary. This command requires root privileges to run. ```bash $GOPATH/src/github.com/google/cadvisor $ sudo ./cadvisor ``` -------------------------------- ### Build Release Artifacts Source: https://github.com/google/cadvisor/blob/master/docs/development/releasing.md Builds the release artifacts using the 'make release' command. Ensure your git client is synced to the release cut point and use a compatible Go version. ```bash make release ``` -------------------------------- ### Apply Daemonset with Custom Overlays Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Applies a cAdvisor Daemonset with your custom patches. Replace `` with the path to your overlay directory. ```bash kubectl kustomize deploy/kubernetes/overlays/ | kubectl apply -f - ``` -------------------------------- ### Enable HTTP Basic Authentication Source: https://github.com/google/cadvisor/blob/master/docs/web.md Use this command to enable HTTP basic authentication for the cAdvisor web UI. Requires a htpasswd file and optionally allows setting a custom auth realm. ```bash ./cadvisor --http_auth_file test.htpasswd --http_auth_realm localhost ``` -------------------------------- ### Set Kafka as Storage Driver Source: https://github.com/google/cadvisor/blob/master/docs/storage/kafka.md Use this flag to enable Kafka as the storage driver for cAdvisor. ```bash -storage_driver=kafka ``` -------------------------------- ### Run cAdvisor on RedHat 7 Source: https://github.com/google/cadvisor/blob/master/docs/running.md This command is specifically for RedHat 7 hosts to address OCI errors. It includes necessary volume mounts and the `--privileged=true` option. ```bash docker run --volume=/:/rootfs:ro --volume=/var/run:/var/run:rw --volume=/sys/fs/cgroup/cpu,cpuacct:/sys/fs/cgroup/cpuacct,cpu --volume=/var/lib/docker/:/var/lib/docker:ro --publish=8080:8080 --detach=true --name=cadvisor --privileged=true google/cadvisor:latest ``` -------------------------------- ### Run Default Docker Integration Tests Source: https://github.com/google/cadvisor/blob/master/docs/development/integration_testing.md Execute the default suite of cAdvisor integration tests using Docker. This command handles building cAdvisor and the integration tests, then runs them against a cAdvisor process. ```bash make docker-test-integration ``` -------------------------------- ### Run Integration Tests Against Existing cAdvisor Instance Source: https://github.com/google/cadvisor/blob/master/docs/development/integration_testing.md Execute integration tests against a cAdvisor instance that is already running. Specify the host and port if they differ from the defaults (localhost and 8080). ```bash $ go test github.com/google/cadvisor/integration/tests/... -host=HOST -port=PORT ``` -------------------------------- ### Configure Perf Events Configuration Path Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Specify the path to a JSON file for configuring perf events. An empty value disables perf event measuring. ```bash --perf_events_config="" ``` -------------------------------- ### Control Aggregation of Core Perf Events Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Demonstrates how to disable 'percpu' metrics to aggregate core perf events, reducing data volume. This can help avoid 'too many opened files' errors. ```bash --disable_metrics="percpu" ``` ```bash --disable_metrics="" ``` -------------------------------- ### Run cAdvisor Unit Tests Source: https://github.com/google/cadvisor/blob/master/docs/development/build.md Execute only the unit tests for cAdvisor using the 'make test' command. This helps verify the correctness of individual components. ```bash $GOPATH/src/github.com/google/cadvisor $ make test ``` -------------------------------- ### Run cAdvisor in a Docker Container Source: https://github.com/google/cadvisor/blob/master/README.md Quickly try out cAdvisor by running it in a Docker container. This command mounts necessary host directories and exposes the cAdvisor UI on port 8080. ```bash VERSION=0.55.1 # use the latest release version from https://github.com/google/cadvisor/releases sudo docker run \ --volume=/:/rootfs:ro \ --volume=/var/run:/var/run:ro \ --volume=/sys:/sys:ro \ --volume=/var/lib/docker/:/var/lib/docker:ro \ --volume=/dev/disk/:/dev/disk:ro \ --publish=8080:8080 \ --detach=true \ --name=cadvisor \ --privileged \ --device=/dev/kmsg \ ghcr.io/google/cadvisor:$VERSION # for versions prior to v0.53.0, use gcr.io/cadvisor/cadvisor instead ``` -------------------------------- ### Generate Base Daemonset Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Generates the base cAdvisor Daemonset manifest using Kustomize. This command outputs the YAML definition without applying it. ```bash kubectl kustomize deploy/kubernetes/base ``` -------------------------------- ### Create Release Branch Source: https://github.com/google/cadvisor/blob/master/docs/development/releasing.md Use this command to create a release branch for major or minor releases. Ensure you are synced to the desired commit before branching. ```bash # Example version VERSION=v0.23 PATCH_VERSION=$VERSION.0 # Sync to HEAD, or the commit to branch at git fetch upstream && git checkout upstream/master # Create the branch git branch release-$VERSION # Push it to upstream git push git@github.com:google/cadvisor.git release-$VERSION ``` -------------------------------- ### Configure Podman Endpoint Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Specifies the endpoint for connecting to the Podman service. The default is a Unix socket. ```bash --podman="unix:///var/run/podman/podman.sock": podman endpoint (default "unix:///var/run/podman/podman.sock") ``` -------------------------------- ### Specify Kafka Broker List Source: https://github.com/google/cadvisor/blob/master/docs/storage/kafka.md Configure the Kafka broker address. Defaults to localhost:9092 if not specified. ```bash -storage_driver_kafka_broker_list=localhost:9092 ``` -------------------------------- ### Deploy cAdvisor with Remote Build Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Deploys cAdvisor to a Kubernetes cluster using Kustomize with a remote build. This command fetches the manifests from a remote URL and applies them to the cluster. ```bash kustomize build "https://github.com/google/cadvisor/deploy/kubernetes/base?ref=${VERSION}" | kubectl apply -f - ``` -------------------------------- ### Configure Debugging and Logging Flags Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Provides cAdvisor-native flags for debugging and logging. These include options for logging stack traces, monitoring cAdvisor's own usage, displaying version information, and enabling profiling. ```bash --log_backtrace_at="": when logging hits line file:N, emit a stack trace ``` ```bash --log_cadvisor_usage=false: Whether to log the usage of the cAdvisor container ``` ```bash --version=false: print cAdvisor version and exit ``` ```bash --profiling=false: Enable profiling via web interface host:port/debug/pprof/ ``` -------------------------------- ### Generate and Apply Daemonset with Perf Support Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Generates and applies the cAdvisor Daemonset with patches for perf support. This includes modifications to the daemonset and configmap for perf events configuration. ```bash kubectl kustomize deploy/kubernetes/overlays/examples_perf | kubectl apply -f - ``` -------------------------------- ### Enable Kafka TLS Client Authentication Source: https://github.com/google/cadvisor/blob/master/docs/storage/kafka.md Configure TLS client authentication for secure Kafka communication. Requires specifying CA certificate, client certificate, and client key paths. SSL verification can be disabled. ```bash # To enable TLS client auth support you need to provide the following: # Location to Certificate Authority certificate -storage_driver_kafka_ssl_ca=/path/to/ca.pem # Location to client certificate certificate -storage_driver_kafka_ssl_cert=/path/to/client_cert.pem # Location to client certificate key -storage_driver_kafka_ssl_key=/path/to/client_key.pem # Verify SSL certificate chain (default: true) -storage_driver_kafka_ssl_verify=false ``` -------------------------------- ### Configure Container Hints Location Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Specifies the file path for container hints, which provide extra information to cAdvisor for augmenting gathered stats. This option is primarily used by the raw container driver. ```bash --container_hints="/etc/cadvisor/container_hints.json": location of the container hints file ``` -------------------------------- ### Configure InfluxDB Connection Details Source: https://github.com/google/cadvisor/blob/master/docs/storage/influxdb.md Set the connection parameters for the InfluxDB instance. These flags allow customization of the host, database name, authentication, secure connection, buffer duration, and retention policy. ```bash # The *ip:port* of the database. Default is 'localhost:8086' -storage_driver_host=ip:port # database name. Uses db 'cadvisor' by default -storage_driver_db # database username. Default is 'root' -storage_driver_user # database password. Default is 'root' -storage_driver_password # Use secure connection with database. False by default -storage_driver_secure # Writes will be buffered for this duration, and committed to the non memory backends as a single transaction. Default is '60s' -storage_driver_buffer_duration # retention policy. Default is '' which corresponds to the default retention policy of the influxdb database -storage_driver_influxdb_retention_policy ``` -------------------------------- ### Configure Housekeeping Intervals Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Sets the intervals for cAdvisor's housekeeping tasks. This includes global housekeeping for detecting new containers and per-container housekeeping for gathering stats. The maximum interval for container housekeeping can also be specified. ```bash --global_housekeeping_interval=1m0s: Interval between global housekeepings ``` ```bash --housekeeping_interval=1s: Interval between container housekeepings ``` ```bash --max_housekeeping_interval=1m0s: Largest interval to allow between container housekeepings (default 1m0s) ``` -------------------------------- ### Enable HTTP Digest Authentication Source: https://github.com/google/cadvisor/blob/master/docs/web.md Use this command to enable HTTP digest authentication for the cAdvisor web UI. Requires a htdigest file and optionally allows setting a custom auth realm. ```bash ./cadvisor --http_digest_file test.htdigest --http_digest_realm localhost ``` -------------------------------- ### Specify Kafka Topic Source: https://github.com/google/cadvisor/blob/master/docs/storage/kafka.md Set the Kafka topic where cAdvisor stats will be published. Defaults to 'stats'. ```bash -storage_driver_kafka_topic=myTopic ``` -------------------------------- ### Specify cgroup mounts for LXC Docker exec driver Source: https://github.com/google/cadvisor/blob/master/docs/running.md When using Docker with the LXC exec driver, you must manually specify all cgroup mounts. This snippet shows the required volume mounts for various cgroup hierarchies. ```bash --volume=/cgroup/cpu:/cgroup/cpu \ --volume=/cgroup/cpuacct:/cgroup/cpuacct \ --volume=/cgroup/cpuset:/cgroup/cpuset \ --volume=/cgroup/memory:/cgroup/memory \ --volume=/cgroup/blkio:/cgroup/blkio \ ``` -------------------------------- ### Configure glog Flags for Logging Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Useful flags inherited from glog for managing log output. Options include specifying a log directory, directing logs to stderr, setting a threshold for stderr logging, controlling verbosity levels, and filtering logs by module. ```bash --log_dir="": If non-empty, write log files in this directory ``` ```bash --logtostderr=false: log to standard error instead of files ``` ```bash --alsologtostderr=false: log to standard error as well as files ``` ```bash --stderrthreshold=0: logs at or above this threshold go to stderr ``` ```bash --v=0: log level for V logs ``` ```bash --vmodule="": comma-separated list of pattern=N settings for file-filtered logging ``` -------------------------------- ### Configure Local Storage Duration Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Set how long cAdvisor should store historical data in memory. ```bash --storage_duration=2m0s ``` -------------------------------- ### Configure Docker Endpoint Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Specifies the endpoint for connecting to the Docker daemon. The default is a Unix socket, but TLS options can be configured for secure connections. ```bash --docker="unix:///var/run/docker.sock": docker endpoint (default "unix:///var/run/docker.sock") ``` ```bash --docker_root="/var/lib/docker": DEPRECATED: docker root is read from docker info (this is a fallback, default: /var/lib/docker) (default "/var/lib/docker") ``` ```bash --docker-tls: use TLS to connect to docker ``` ```bash --docker-tls-cert="cert.pem": client certificate for TLS-connection with docker ``` ```bash --docker-tls-key="key.pem": private key for TLS-connection with docker ``` ```bash --docker-tls-ca="ca.pem": trusted CA for TLS-connection with docker ``` -------------------------------- ### Set Elasticsearch Storage Driver Source: https://github.com/google/cadvisor/blob/master/docs/storage/elasticsearch.md Configure cAdvisor to use Elasticsearch as its storage backend. ```bash -storage_driver=elasticsearch ``` -------------------------------- ### BigQuery Storage Driver Configuration Flags Source: https://github.com/google/cadvisor/blob/master/cmd/internal/storage/bigquery/README.md Flags required to configure cAdvisor to use the BigQuery storage driver, including authentication credentials and project ID. ```bash # Storage driver to use. -storage_driver=bigquery # Information about server-to-server Oauth token. # These can be obtained by creating a Service Account client id under `Google Developer API` # service client id -bq_id="XYZ.apps.googleusercontent.com" # service email address -bq_account="ABC@developer.gserviceaccount.com" # path to pem key (converted from p12 file) -bq_credentials_file="/path/to/key.pem" # project id to use for storing datasets. -bq_project_id="awesome_project" ``` -------------------------------- ### Configure Metrics Collection Limits and Endpoints Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Control the number of application metrics stored and the endpoint for Prometheus metrics. ```bash --application_metrics_count_limit=100 --collector_cert="" --collector_key="" --prometheus_endpoint="/metrics" --disable_root_cgroup_stats=false ``` -------------------------------- ### Configure CPU Settings Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Flags to control CPU-related functionalities. The `enable_load_reader` flag determines if CPU load reader is enabled, while `max_procs` sets the maximum number of CPUs that can be used simultaneously. ```bash --enable_load_reader=false: Whether to enable cpu load reader ``` ```bash --max_procs=0: max number of CPUs that can be used simultaneously. Less than 1 for default (number of cores). ``` -------------------------------- ### Selected Metrics from Prometheus Endpoint Configuration Source: https://github.com/google/cadvisor/blob/master/docs/application_metrics.md This configuration allows you to specify a subset of metrics to collect from a Prometheus endpoint. It includes the endpoint URL and a list of specific metric names to be scraped. ```json { "endpoint" : "http://localhost:8000/metrics", "metrics_config" : [ "scheduler_binding_latency", "scheduler_e2e_scheduling_latency", "scheduling_algorithm_latency" ] } ``` -------------------------------- ### Container Information API v1.0 Source: https://github.com/google/cadvisor/blob/master/docs/api.md Retrieves information for a specified container using the lmctfy naming convention. ```APIDOC ## GET /api/v1.0/containers/ ### Description Retrieves information for a specified container using the lmctfy naming convention. The root container ('/') provides usage for the entire machine. Docker containers are listed under '/docker'. ### Method GET ### Endpoint /api/v1.0/containers/ ### Response #### Success Response (200) - A JSON object containing: - Absolute container name (string) - List of subcontainers (array) - ContainerSpec (object) which describes the resource isolation enabled in the container - Detailed resource usage statistics of the container for the last `N` seconds - Histogram of resource usage from the creation of the container - The actual object is the marshalled JSON of the `ContainerInfo` struct. ``` -------------------------------- ### Configure Elasticsearch Type Name Source: https://github.com/google/cadvisor/blob/master/docs/storage/elasticsearch.md Optionally set the document type name in Elasticsearch. Defaults to 'stats'. ```bash # ElasticSearch type name. By default it's "stats". -storage_driver_es_type="stats" ``` -------------------------------- ### Apply Base Daemonset Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Applies the base cAdvisor Daemonset to your Kubernetes cluster. This command generates the manifest and pipes it directly to kubectl for application. ```bash kubectl kustomize deploy/kubernetes/base | kubectl apply -f - ``` -------------------------------- ### Docker Container Information API v1.2 Source: https://github.com/google/cadvisor/blob/master/docs/api.md Retrieves information for specified Docker containers or all Docker containers if no name is provided. ```APIDOC ## GET /api/v1.2/docker/ ### Description Retrieves information for specified Docker containers or all Docker containers if no name is provided. The Docker name can be a UUID or a short name. ### Method GET ### Endpoint /api/v1.2/docker/ ### Response #### Success Response (200) - A list of serialized `ContainerInfo` JSON objects. ``` -------------------------------- ### Set Storage Driver to Statsd Source: https://github.com/google/cadvisor/blob/master/docs/storage/statsd.md Configure cAdvisor to use Statsd as its storage driver. This is the primary flag to enable Statsd export. ```bash -storage_driver=statsd ``` -------------------------------- ### Update cAdvisor Image Version Source: https://github.com/google/cadvisor/blob/master/deploy/kubernetes/README.md Updates the image version for cAdvisor within the Kustomize base configuration. Navigate to the base directory, set the new image, and return to the parent directory. ```bash cd deploy/kubernetes/base && kustomize edit set image ghcr.io/google/cadvisor:${VERSION} && cd ../../.. ``` -------------------------------- ### Configure Dynamic Housekeeping Source: https://github.com/google/cadvisor/blob/master/docs/runtime_options.md Controls whether cAdvisor is allowed to dynamically adjust housekeeping intervals based on container activity. Disabling this provides predictable intervals but may increase resource usage. ```bash --allow_dynamic_housekeeping=true: Whether to allow the housekeeping interval to be dynamic ``` -------------------------------- ### Generic Metric Collector Configuration Source: https://github.com/google/cadvisor/blob/master/docs/application_metrics.md Use this configuration to collect metrics from an endpoint that does not expose structured information like Prometheus. It requires specifying details for each metric, including its name, type, units, data type, polling frequency, and a regular expression for parsing. ```json { "endpoint" : "http://localhost:8000/nginx_status", "metrics_config" : [ { "name" : "activeConnections", "metric_type" : "gauge", "units" : "number of active connections", "data_type" : "int", "polling_frequency" : 10, "regex" : "Active connections: ([0-9]+)" }, { "name" : "reading", "metric_type" : "gauge", "units" : "number of reading connections", "data_type" : "int", "polling_frequency" : 10, "regex" : "Reading: ([0-9]+) .*" } ] } ``` -------------------------------- ### MachineInfo Source: https://github.com/google/cadvisor/blob/master/client/README.md Retrieves all information about the machine the cAdvisor is running on. This includes details about CPU cores, memory capacity, and filesystem information. ```APIDOC ## MachineInfo ### Description Retrieves all information about the machine the cAdvisor is running on. This includes details about CPU cores, memory capacity, and filesystem information. ### Method GET (inferred) ### Endpoint /machine ### Parameters None ### Response #### Success Response (200) - **NumCores** (int) - The number of CPU cores available. - **MemoryCapacity** (int64) - The total system memory capacity in bytes. - **Filesystems** ([]FsInfo) - A list of filesystem information structures. - **Device** (string) - The device name of the filesystem. - **Capacity** (uint64) - The total capacity of the filesystem in bytes. ### Response Example ```json { "NumCores": 4, "MemoryCapacity": 2106028032, "Filesystems": [ { "Device": "/dev/sda1", "Capacity": 19507089408 } ] } ``` ``` -------------------------------- ### ContainerInfo Source: https://github.com/google/cadvisor/blob/master/client/README.md Retrieves all information about a specific container, identified by its name. It can also fetch a specified number of recent statistics for the container. ```APIDOC ## ContainerInfo ### Description Retrieves all information about a specific container, identified by its name. It can also fetch a specified number of recent statistics for the container. ### Method GET (inferred) ### Endpoint /containers/{container_name} ### Parameters #### Path Parameters - **container_name** (string) - Required - The name of the container to retrieve information for. #### Query Parameters - **num_stats** (int) - Optional - The number of recent statistics to include. ### Request Example ```json { "num_stats": 10 } ``` ### Response #### Success Response (200) - **ContainerInfo** (struct) - A struct containing detailed information about the container. #### Response Example (Response structure depends on the ContainerInfo struct definition) ``` -------------------------------- ### Specify Statsd Host and Port Source: https://github.com/google/cadvisor/blob/master/docs/storage/statsd.md Define the network address for the Statsd instance where cAdvisor will send data. The default is 'localhost:8086'. ```bash # The *ip:port* of the instance. Default is 'localhost:8086' -storage_driver_host=ip:port ```