prometheus.exporter.cadvisor
General availability (GA)

prometheus.exporter.cadvisor

The prometheus.exporter.cadvisor component collects container metrics using cAdvisor.

Usage

alloy
prometheus.exporter.cadvisor "<LABEL>" {
}

Arguments

You can use the following arguments with prometheus.exporter.cadvisor:

NameTypeDescriptionDefaultRequired
allowlisted_container_labelslist(string)Allowlist of container labels to convert to Prometheus labels.[]no
containerd_hoststringThe containerd endpoint./run/containerd/containerd.sockno
containerd_namespacestringThe containerd namespace.k8s.iono
disable_root_cgroup_statsboolDisable collecting root Cgroup stats.falseno
disabled_metricslist(string)List of metrics to be disabled which, if set, overrides the default disabled metrics.(see below)no
docker_hoststringDocker endpoint.unix:///var/run/docker.sockno
docker_onlyboolOnly report docker containers in addition to root stats.falseno
docker_tls_castringPath to a trusted CA for TLS connection to docker.ca.pemno
docker_tls_certstringPath to client certificate for TLS connection to docker.cert.pemno
docker_tls_keystringPath to private key for TLS connection to docker.key.pemno
enabled_metricslist(string)List of metrics to be enabled which, if set, overrides disabled_metrics.[]no
env_metadata_allowlistlist(string)Allowlist of environment variable keys matched with a specified prefix that needs to be collected for containers.[]no
perf_events_configstringPath to a JSON file containing the configuration of perf events to measure.""no
raw_cgroup_prefix_allowlistlist(string)List of cgroup path prefixes that need to be collected, even when docker_only is specified.[]no
resctrl_intervaldurationInterval to update resctrl mon groups.0no
storage_durationdurationLength of time to keep data stored in memory.2mno
store_container_labelsboolWhether to convert container labels and environment variables into labels on Prometheus metrics for each container.trueno
use_docker_tlsboolUse TLS to connect to docker.falseno

For allowlisted_container_labels to take effect, store_container_labels must be set to false.

env_metadata_allowlist is only supported for containerd and Docker runtimes.

If perf_events_config is not set, measurement of perf events is disabled.

A resctrl_interval of 0 disables updating mon groups.

The values for enabled_metrics and disabled_metrics don’t correspond to Prometheus metrics, but to kinds of metrics that should or shouldn’t be exposed. The values that you can use are:

  • "advtcp"
  • "app"
  • "cpu_topology"
  • "cpu"
  • "cpuLoad"
  • "cpuset"
  • "disk"
  • "diskIO"
  • "hugetlb"
  • "memory_numa"
  • "memory"
  • "network"
  • "oom_event"
  • "percpu"
  • "perf_event"
  • "process"
  • "referenced_memory"
  • "resctrl"
  • "sched"
  • "tcp"
  • "udp"

By default the following metric kinds are disabled:

  • "advtcp"
  • "cpu_topology"
  • "cpuset"
  • "hugetlb"
  • "memory_numa"
  • "process"
  • "referenced_memory"
  • "resctrl"
  • "tcp"
  • "udp"

Blocks

The prometheus.exporter.cadvisor component doesn’t support any blocks. You can configure this component with arguments.

Exported fields

The following fields are exported and can be referenced by other components.

NameTypeDescription
targetslist(map(string))The targets that can be used to collect exporter metrics.

For example, the targets can either be passed to a discovery.relabel component to rewrite the targets’ label sets or to a prometheus.scrape component that collects the exposed metrics.

The exported targets use the configured in-memory traffic address specified by the run command.

Component health

prometheus.exporter.cadvisor is only reported as unhealthy if given an invalid configuration. In those cases, exported fields retain their last healthy values.

Debug information

prometheus.exporter.cadvisor doesn’t expose any component-specific debug information.

Debug metrics

prometheus.exporter.cadvisor doesn’t expose any component-specific debug metrics.

Example

This example uses a prometheus.scrape component to collect metrics from prometheus.exporter.cadvisor:

alloy
prometheus.exporter.cadvisor "example" {
  docker_host = "unix:///var/run/docker.sock"

  storage_duration = "5m"
}

// Configure a prometheus.scrape component to collect cadvisor metrics.
prometheus.scrape "scraper" {
  targets    = prometheus.exporter.cadvisor.example.targets
  forward_to = [ prometheus.remote_write.demo.receiver ]
}

prometheus.remote_write "demo" {
  endpoint {
    url = "<PROMETHEUS_REMOTE_WRITE_URL>"

    basic_auth {
      username = "<USERNAME>"
      password = "<PASSWORD>"
    }
  }
}

Replace the following:

  • <PROMETHEUS_REMOTE_WRITE_URL>: The URL of the Prometheus remote_write compatible server to send metrics to.
  • <USERNAME>: The username to use for authentication to the remote_write API.
  • <PASSWORD>: The password to use for authentication to the remote_write API.

Compatible components

prometheus.exporter.cadvisor has exports that can be consumed by the following components:

Note

Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.