Skip to content

[receiver/vcenter] Add host, datastore and VM state metrics - #50933

Draft
Harshit1259 wants to merge 5 commits into
open-telemetry:mainfrom
Harshit1259:vcenter-47176-metadata-kpis
Draft

[receiver/vcenter] Add host, datastore and VM state metrics#50933
Harshit1259 wants to merge 5 commits into
open-telemetry:mainfrom
Harshit1259:vcenter-47176-metadata-kpis

Conversation

@Harshit1259

@Harshit1259 Harshit1259 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Description

  1. This PR adds 7 vCenter state metrics that are available in pryorda/vmware_exporter but missing in the OTel vCenter receiver.
  2. It is mainly useful for users migrating from Pryorda who want similar monitoring coverage after migration.
  3. All 7 metrics are disabled by default and need to be explicitly enabled.
  4. Compared with Pryorda, power state changes from a 0/1 value to state-based attributes, so existing power-state alerts need to be updated; connection and maintenance also use different label names and snake_case values. Boot timestamp is replaced with uptime in seconds, while alarms are exposed as red/yellow counts without alarm names.

Metrics added:

  • vcenter.host.power.status
  • vcenter.host.connection.status
  • vcenter.host.uptime
  • vcenter.host.alarm.count
  • vcenter.datastore.maintenance.status
  • vcenter.datastore.alarm.count
  • vcenter.vm.power.status

Link to tracking issue

Part of #47176

Testing

Added unit tests in metrics_test.go to cover all 7 new metrics using sample input data and verify the expected output.

Also updated scraper_test.go to test the complete scrape flow with mocked vCenter responses and compare the results with the golden files.

expected.yaml remains unchanged, which confirms the new metrics are disabled by default, while expected-all-enabled.yaml includes all 7 metrics when they are enabled.

Documentation

Regenerated documentation.md using make generate so all 7 new metrics are now documented with their description, unit, metric type, and supported attribute values.

The metrics are listed under Optional Metrics, which also confirms that they are disabled by default.

Added the required metric descriptions in metadata.yaml.

Also added the changelog entry .chloggen/vcenter-47176-metadata-kpis.yaml as an enhancement, listing all 7 metrics and mentioning that they are disabled by default.

Solved Standby Power-State Bug

The host power-state mapping was using "standby", but vSphere actually returns "standBy", so standby hosts were incorrectly reported as unknown.

This also affected the new vcenter.host.power_state metric, since it uses the same mapping. The fix replaces the manually typed values with govmomi constants, so standby hosts are now reported correctly as standby.

Added tests for both the new host power-state metric and the existing vcenter.datacenter.host.count metric, and added a separate bug-fix changelog entry because this changes existing output.

Authorship

  • I, a human, wrote this pull request description myself.

Add opt-in state metrics requested in open-telemetry#47176 for users migrating from
vmware_exporter: host power state, connection state, uptime and
triggered alarm count, datastore maintenance mode and triggered alarm
count, and VM power state. All new metrics are disabled by default.

Assisted-by: Claude Opus 5
Claude-Session: https://claude.ai/code/session_01BqWofePsmD4ZQtnzmicQKe
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Comment thread receiver/vcenterreceiver/metadata.yaml Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants