Skip to content

[receiver/dockerstats] Dimensions not created without explicit mapping via config. #16032

Closed as not planned
@austinlparker

Description

What happened?

Description

When enabling the docker stats receiver, metrics do not receive per-container dimensions by default. I had to add the following to get dimensions:

    container_labels_to_metric_labels:
      com.docker.compose.service: service.name

Steps to Reproduce

Enable dockerstats receiver with no additional config using the opentelemetry demo app.
(Bind the Docker socket into the collector container and set user: "0:0" as well)

Expected Result

Labels would be added for container names.

Actual Result

Labels are not added for container name.

Collector version

0.63.1

Environment information

Environment

OS: macOS Ventura
Running collector-contrib docker container.

OpenTelemetry Collector configuration

receivers:
  otlp:
    protocols:
      grpc:
      http:
        cors:
          allowed_origins:
            - "http://*"
            - "https://*"
  otlp/spanmetrics:
    protocols:
      grpc:
        endpoint: "localhost:65535"
  docker_stats:

exporters:
  otlp:
    endpoint: "jaeger:4317"
    tls:
      insecure: true
  logging:
  prometheus:
    endpoint: "otelcol:9464"


processors:
  batch:
  spanmetrics:
    metrics_exporter: prometheus
  resourcedetection:
    detectors: [docker]

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [spanmetrics, batch]
      exporters: [logging, otlp]
    metrics:
      receivers: [otlp, docker_stats]
      processors: [resourcedetection, batch]
      exporters: [prometheus, logging]
    metrics/spanmetrics:
      receivers: [ otlp/spanmetrics ]
      exporters: [ prometheus, logging ]

Log output

Output at /metrics without the additional config:


# HELP container_cpu_percent Percent of CPU used by the container.
# TYPE container_cpu_percent gauge
container_cpu_percent 0.09058823529411765

Output at /metrics with the additional config:

# HELP container_cpu_percent Percent of CPU used by the container.
# TYPE container_cpu_percent gauge
container_cpu_percent{job="adservice"} 0.3043192488262911
container_cpu_percent{job="cartservice"} 2.744461778471139
container_cpu_percent{job="checkoutservice"} 0.03446009389671362
container_cpu_percent{job="currencyservice"} 0.08143525741029642
container_cpu_percent{job="emailservice"} 0.032582159624413146
container_cpu_percent{job="featureflagservice"} 2.6804368174726987
container_cpu_percent{job="ffs_postgres"} 0.448262910798122
container_cpu_percent{job="frontend"} 2.475163806552262
container_cpu_percent{job="frontendproxy"} 0.9003755868544602
container_cpu_percent{job="grafana"} 0.13020280811232451
container_cpu_percent{job="jaeger"} 0.8588087774294672
container_cpu_percent{job="loadgenerator"} 1.353978159126365
container_cpu_percent{job="otelcol"} 4.52371875
container_cpu_percent{job="paymentservice"} 0.06112676056338028
container_cpu_percent{job="productcatalogservice"} 0.21890109890109888
container_cpu_percent{job="prometheus"} 0
container_cpu_percent{job="quoteservice"} 0.02124804992199688
container_cpu_percent{job="recommendationservice"} 2.9113964686998397
container_cpu_percent{job="redis-cart"} 0.43873817034700313
container_cpu_percent{job="shippingservice"} 0


### Additional context

_No response_

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions