Menu

This is documentation for the next version of Alloy. For the latest stable release, go to the latest version.

Open source

prometheus.exporter.cadvisor

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

Usage

alloy
prometheus.exporter.cadvisor "LABEL" {
}

Arguments

The following arguments can be used to configure the exporter’s behavior. All arguments are optional. Omitted fields take their default values.

NameTypeDescriptionDefaultRequired
store_container_labelsboolWhether to convert container labels and environment variables into labels on Prometheus metrics for each container.trueno
allowlisted_container_labelslist(string)Allowlist of container labels to convert to Prometheus labels.[]no
env_metadata_allowlistlist(string)Allowlist of environment variable keys matched with a specified prefix that needs to be collected for containers.[]no
raw_cgroup_prefix_allowlistlist(string)List of cgroup path prefixes that need to be collected, even when docker_only is specified.[]no
perf_events_configstringPath to a JSON file containing the configuration of perf events to measure.""no
resctrl_intervaldurationInterval to update resctrl mon groups.0no
disabled_metricslist(string)List of metrics to be disabled which, if set, overrides the default disabled metrics.(see below)no
enabled_metricslist(string)List of metrics to be enabled which, if set, overrides disabled_metrics.[]no
storage_durationdurationLength of time to keep data stored in memory.2mno
containerd_hoststringContainerd endpoint./run/containerd/containerd.sockno
containerd_namespacestringContainerd namespace.k8s.iono
docker_hoststringDocker endpoint.unix:///var/run/docker.sockno
use_docker_tlsboolUse TLS to connect to docker.falseno
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
docker_tls_castringPath to a trusted CA for TLS connection to docker.ca.pemno
docker_onlyboolOnly report docker containers in addition to root stats.falseno
disable_root_cgroup_statsboolDisable collecting root Cgroup stats.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 do not correspond to Prometheus metrics, but to kinds of metrics that should (or shouldn’t) be exposed. The full list of values that can be used is

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

By default the following metric kinds are disabled: "memory_numa", "tcp", "udp", "advtcp", "process", "hugetlb", "referenced_memory", "cpu_topology", "resctrl", "cpuset"

Blocks

The prometheus.exporter.cadvisor component does not support any blocks, and is configured fully through 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 does not expose any component-specific debug information.

Debug metrics

prometheus.exporter.cadvisor does not 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.