Skip to content

vcenterreceiver panics on VM metric collection (nil pointer dereference in buildVMMetrics) #41018

@Mhmd-Elsabaa

Description

@Mhmd-Elsabaa

The otelcol-contrib process crashes during VM metric collection from a vCenter instance with a nil pointer dereference in buildVMMetrics. It appears to be caused by an unexpected nil in the VM object returned by the vSphere API (likely vm.Config.Hardware or vm.Summary fields).

Logs:
panic: runtime error: invalid memory address or nil pointer dereference
goroutine 147 [running]:
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(...)
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver.(*vcenterMetricScraper).buildVMMetrics
processors.go:310
github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver.(*vcenterMetricScraper).processVMs
processors.go:228
...

Config
receivers:
vcenter:
endpoint: https://
username: ...
password: ...
collection_interval: 60s
insecure: true

processors:
batch:

exporters:
prometheus:
endpoint: "0.0.0.0:9464"

service:
pipelines:
metrics/vcenter:
receivers: [vcenter]
processors: [batch]
exporters: [prometheus]

Request
Please guard against nil dereferences in buildVMMetrics to avoid crashing the entire collector. A panic on one VM should not take down the pipeline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions