opentelemetry-collector-contrib icon indicating copy to clipboard operation
opentelemetry-collector-contrib copied to clipboard

[receiver/hostmetrics] Network info from within container despite mounting /hostfs

Open dhilgarth opened this issue 6 months ago • 4 comments

Component(s)

receiver/hostmetrics

What happened?

Description

My otel collector is running in a container. I've followed the documentation to ensure that it is actually monitoring the host and not the container. And this works for everything except network.
My host has the interface enp7s0 and no interface eth0 or eth1.
Yet, I get data for eth0 and eth1 - as you can see below, the container is in two networks - and not für enp7s0

Collector version

0.106.1

Environment information

Environment

OS: "Ubuntu 22.04" Docker Swarm: "Docker version 24.0.7, build 24.0.7-0ubuntu2~22.04.1"

OpenTelemetry Collector configuration

receivers:
  hostmetrics:
    collection_interval: 15s
    root_path: /hostfs
    scrapers:
      cpu:
        metrics:
          system.cpu.logical.count:
            enabled: true
          system.cpu.physical.count:
            enabled: true
          system.cpu.frequency:
            enabled: true
          system.cpu.utilization:
            enabled: true
      load: {}
      memory:
        metrics:
          system.linux.memory.available:
            enabled: true
          system.memory.limit:
            enabled: true
          system.memory.utilization:
            enabled: true
      disk: {}
      filesystem:
        metrics:
          system.filesystem.utilization:
            enabled: true
      paging:
        metrics:
          system.paging.utilization:
            enabled: true
          system.paging.usage:
            enabled: true
      network: {}
      process:
        mute_process_io_error: true
        mute_process_exe_error: true
        mute_process_user_error: true
        metrics:
          process.cpu.utilization:
            enabled: true
          process.memory.utilization:
            enabled: true
          process.disk.io:
            enabled: true
          process.disk.operations:
            enabled: true
          process.threads:
            enabled: true
          process.paging.faults:
            enabled: true

Log output

No response

Additional context

This is the Docker Swarm Service definition:

docker service inspect --pretty otel-collector

ID:             n38j4io4frootqte5d7iwbft1
Name:           otel-collector
Labels:
 com.docker.stack.image=otel/opentelemetry-collector-contrib:0.106.1
 com.docker.stack.namespace=monitoring
Service Mode:   Global
Placement:
 Constraints:   [node.platform.os == linux]
ContainerSpec:
 Image:         otel/opentelemetry-collector-contrib:0.106.1
 Args:          --config=/etc/otel-collector-config.yaml --feature-gates=-pkg.translator.prometheus.NormalizeName
 Env:           OTEL_RESOURCE_ATTRIBUTES=host.name={{.Node.Hostname}},os.type={{.Node.Platform.OS}},dockerswarm.service.name={{.Service.Name}},dockerswarm.task.name={{.Task.Name}}
 User: 0
Mounts:
 Target:        /hostfs
  Source:       /
  ReadOnly:     true
  Type:         bind
 Target:        /var/run/docker.sock
  Source:       /var/run/docker.sock
  ReadOnly:     true
  Type:         bind
 Target:        /var/lib/docker/containers
  Source:       /var/lib/docker/containers
  ReadOnly:     true
  Type:         bind
Configs:
 Target:        /etc/otel-collector-config.yaml
  Source:       otel-collector-config_XRNDChoHzH_Dsg
Resources:
Networks: web_new monitoring_new
Endpoint Mode:  vip

dhilgarth avatar Aug 03 '24 07:08 dhilgarth