dockerstatsreceiver

package module
v0.98.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 19 Imported by: 10

README

Docker Stats Receiver

Status
Stability alpha: metrics
Unsupported Platforms darwin, windows
Distributions contrib
Issues Open issues Closed issues
Code Owners @rmfitzpatrick, @jamesmoessis

The Docker Stats receiver queries the local Docker daemon's container stats API for all desired running containers on a configured interval. These stats are for container resource usage of cpu, memory, network, and the blkio controller.

ℹ Requires Docker API version 1.22+ and only Linux is supported.

Configuration

The following settings are optional:

  • endpoint (default = unix:///var/run/docker.sock): Address to reach the desired Docker daemon.
  • collection_interval (default = 10s): The interval at which to gather container stats.
  • initial_delay (default = 1s): defines how long this receiver waits before starting.
  • container_labels_to_metric_labels (no default): A map of Docker container label names whose label values to use as the specified metric label key.
  • env_vars_to_metric_labels (no default): A map of Docker container environment variables whose values to use as the specified metric label key.
  • excluded_images (no default, all running containers monitored): A list of strings, regexes, or globs whose referent container image names will not be among the queried containers. !-prefixed negations are possible for all item types to signify that only unmatched container image names should be excluded.
    • Regexes must be placed between / characters: /my?egex/. Negations are to be outside the forward slashes: !/my?egex/ will exclude all containers whose name doesn't match the compiled regex my?egex.
    • Globs are non-regex items (e.g. /items/) containing any of the following: *[]{}?. Negations are supported: !my*container will exclude all containers whose image name doesn't match the blob my*container.
  • timeout (default = 5s): The request timeout for any docker daemon query.
  • api_version (default = 1.25): The Docker client API version (must be 1.25+). If using one with a terminating zero, input as a string to prevent undesired truncation (e.g. "1.40" instead of 1.40, which is parsed as 1.4). Docker API versions.
  • metrics (defaults at ./documentation.md): Enables/disables individual metrics. See ./documentation.md for full detail.

Example:

receivers:
  docker_stats:
    endpoint: http://example.com/
    collection_interval: 2s
    timeout: 20s
    api_version: 1.24
    container_labels_to_metric_labels:
      my.container.label: my-metric-label
      my.other.container.label: my-other-metric-label
    env_vars_to_metric_labels:
      MY_ENVIRONMENT_VARIABLE: my-metric-label
      MY_OTHER_ENVIRONMENT_VARIABLE: my-other-metric-label
    excluded_images:
      - undesired-container
      - /.*undesired.*/
      - another-*-container
    metrics: 
      container.cpu.usage.percpu:
        enabled: true
      container.network.io.usage.tx_dropped:
        enabled: false

The full list of settings exposed for this receiver are documented here with detailed sample configurations here.

Deprecations

Transition to cpu utilization metric name aligned with OpenTelemetry specification

The Docker Stats receiver has been emitting the following cpu memory metric:

  • [container.cpu.percent] for the percentage of CPU used by the container,

This is in conflict with the OpenTelemetry specification, which defines [container.cpu.utilization] as the name for this metric.

To align the emitted metric names with the OpenTelemetry specification, the following process will be followed to phase out the old metrics:

  • Between v0.79.0 and v0.86.0, the new metric is introduced and the old metric is marked as deprecated. Only the old metric are emitted by default.
  • In v0.88.0, the old metric is disabled and the new one enabled by default.
  • In v0.89.0 and up, the old metric is removed.

To change the enabled state for the specific metrics, use the standard configuration options that are available for all metrics.

Here's an example configuration to disable the old metrics and enable the new metrics:

receivers:
  docker_stats:
    metrics:
      container.cpu.percent:
        enabled: false
      container.cpu.utilization:
        enabled: true

Migrating from ScraperV1 to ScraperV2

Note: These changes are now in effect and ScraperV1 have been removed as of v0.71.

There are some breaking changes from ScraperV1 to ScraperV2. The work done for these changes is tracked in #9794.

Breaking Change Action
Many metrics are no longer emitted by default. See documentation.md to see which metrics are enabled by default. Enable/disable as desired.
BlockIO metrics names changed. The type of operation is no longer in the metric name suffix, and is now in an attribute. For example container.blockio.io_merged_recursive.read becomes container.blockio.io_merged_recursive with an operation:read attribute. Be aware of the metric name changes and make any adjustments to what your downstream expects from BlockIO metrics.
Memory metrics measured in Bytes are now non-monotonic sums instead of gauges. Most likely there is no action. The aggregation type is different but the values are the same. Be aware of how your downstream handles gauges vs non-monotonic sums.
Config option provide_per_core_cpu_metrics has been removed. Enable the container.cpu.usage.percpu metric as per documentation.md.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

Types

type Config

type Config struct {
	scraperhelper.ControllerConfig `mapstructure:",squash"`
	// The URL of the docker server.  Default is "unix:///var/run/docker.sock"
	Endpoint string `mapstructure:"endpoint"`

	// A mapping of container label names to MetricDescriptor label keys.
	// The corresponding container label value will become the DataPoint label value
	// for the mapped name.  E.g. `io.kubernetes.container.name: container_spec_name`
	// would result in a MetricDescriptor label called `container_spec_name` whose
	// Metric DataPoints have the value of the `io.kubernetes.container.name` container label.
	ContainerLabelsToMetricLabels map[string]string `mapstructure:"container_labels_to_metric_labels"`

	// A mapping of container environment variable names to MetricDescriptor label
	// keys.  The corresponding env var values become the DataPoint label value.
	// E.g. `APP_VERSION: version` would result MetricDescriptors having a label
	// key called `version` whose DataPoint label values are the value of the
	// `APP_VERSION` environment variable configured for that particular container, if
	// present.
	EnvVarsToMetricLabels map[string]string `mapstructure:"env_vars_to_metric_labels"`

	// A list of filters whose matching images are to be excluded.  Supports literals, globs, and regex.
	ExcludedImages []string `mapstructure:"excluded_images"`

	// Docker client API version. Default is 1.22
	DockerAPIVersion string `mapstructure:"api_version"`

	// MetricsBuilderConfig config. Enable or disable stats by name.
	metadata.MetricsBuilderConfig `mapstructure:",squash"`
}

func (Config) Validate

func (config Config) Validate() error

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL