Skip to content

[receiver/hostmetrics] permission denied on Linux #20435

Open
SumoLogic/sumologic-otel-collector
#1228
@flenoir

Description

@flenoir

Describe the bug
I want to get process metrics of a linux station. So i'm using a collector as an agent with "hostmetrics". When launching the service, i get errors on "process" scraping. the message returns permission denied error for all PIDs.

Steps to reproduce

Being root on the ubuntu system
Download v0.74.0 of the contrib collector deb file (otel-contrib-collector_0.74.0_amd64.deb)
Install contrib collector: dpkg --install otel-contrib-collector_0.74.0_amd64.deb
Configure it to collect host metrics (specifically, process data) via the hostmetrics receiver and process scraper

What did you expect to see?
No errors

What did you see instead?
Every minute, an error message is generated complaining about error reading process name ... permission denied for seemingly every PID on the machine:

error reading process name for pid 1165232: readlink /proc/1165232/exe: permission denied; error reading process name for pid 1165265: readlink /proc/1165265/exe: permission denied; error reading process name for pid 1166088: readlink /proc/1166088/exe: permission denied; error reading process name for pid 1166634: readlink /proc/1166634/exe: permission denied; error reading process name for pid 1166826: readlink /proc/1166826/exe: permission denied; error reading process name for pid 1166827: readlink /proc/1166827/exe: permission denied; error reading process name for pid 1166874: readlink /proc/1166874/exe: permission denied; error reading process name for pid 1168213: readlink /proc/1168213/exe: permission denied; error reading process name for pid 1168214: readlink /proc/1168214/exe: permission denied; error reading process name for pid 1168221: readlink /proc/1168221/exe: permission denied; error reading process name for pid 1168222: readlink /proc/1168222/exe: permission denied", "scraper": "process"}

What version did you use?
v0.74.0 of the contrib collector (https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v0.74.0/otelcol-contrib_0.74.0_linux_amd64.deb)

What config did you use?
config.yaml

extensions:
  health_check:
  pprof:
    endpoint: 0.0.0.0:1777
  zpages:
    endpoint: 0.0.0.0:55679

receivers:
  otlp:
    protocols:
      grpc:
      http:

  opencensus:
  hostmetrics:
    collection_interval: 30s
    root_path: /
    scrapers:
      cpu:
      memory:
      load:
      filesystem:
      network:
      paging:
      process:
      processes:

  # Collect own metrics
  prometheus:
    config:
      scrape_configs:
      - job_name: 'otel-collector-toto'
        scrape_interval: 10s
        static_configs:
        - targets: ['0.0.0.0:8888']

  jaeger:
    protocols:
      grpc:
      thrift_binary:
      thrift_compact:
      thrift_http:

  zipkin:

processors:
  batch:
  resource: 
    attributes:
    - key: service.name
      value: machine_toto
      action: upsert
    - key: service.namespace
      value: fl001
      action: upsert
    - key: namespace
      value: test_pc_toto0001
      action: upsert
    - key: cluster
      value: linux_ubuntu
      action: upsert
  resourcedetection:
    detectors: ["system"]
    system:
      hostname_sources: ["os"]

exporters:
  logging:
    verbosity: detailed
  otlp/tempo:
    endpoint: [myendpoint-hidden]:80
    tls:
      insecure: true

service:

  pipelines:
    traces:
      receivers: [otlp, opencensus, jaeger, zipkin]
      processors: [batch]
      exporters: [logging, otlp/tempo]

    metrics:
      receivers: [otlp, opencensus, prometheus, hostmetrics]
      processors: [resource, resourcedetection, batch]
      exporters: [logging, otlp/tempo]

  extensions: [health_check, pprof, zpages]

service file

[Unit]
Description=OpenTelemetry Collector Contrib
After=network.target

[Service]
EnvironmentFile=/etc/otelcol-contrib/otelcol-contrib.conf
ExecStart=/usr/bin/otelcol-contrib $OTELCOL_OPTIONS
KillMode=mixed
Restart=on-failure
Type=simple
User=otelcol-contrib
Group=otelcol-contrib

[Install]
WantedBy=multi-user.target

If i add a "sudo" in exec start, or if a chnage User to "root", error changes to :

1163933: readlink /proc/1163933/exe: no such file or directory; error reading process name for pid 1163935: readlink /proc/1163935/exe: no such file or directory; error reading username for process \"gjs\" (pid 1163938): user: unknown userid 1472934163; error reading process name for pid 1164151: readlink /proc/1164151/exe: no such file or directory; error reading process name for pid 1164366: readlink /proc/1164366/exe: no such file or directory; error reading username for process \"brave\" (pid 1165232): user: unknown userid 1472934163; error reading process name for pid 1165263: readlink /proc/1165263/exe: no such file or directory; error reading process name for pid 1165265: readlink /proc/1165265/exe: no such file or directory; error reading username for process \"sudo\" (pid 1166027): user: unknown userid 1472934163; error reading username for process \"grep\" (pid 1166028): user: unknown userid 1472934163; error reading username for process \"sudo\" (pid 1166035): user: unknown userid 1472934163; error reading process name for pid 1166088: readlink /proc/1166088/exe: no such file or directory", "scraper": "process"}

Environment
OS: Ubuntu 22.04

Additional context
N/A

I also have to mention that i found a closed similar issue which didn't helped me to resolve the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    never staleIssues marked with this label will be never staled and automatically removedreceiver/hostmetrics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions