Skip to content

Conversation

@peytonr18
Copy link

@peytonr18 peytonr18 commented Oct 30, 2025

Proposed Commit Message

feat(azure): add vm_id to KVP telemetry event keys

Add VM ID to the KVP (Key-Value Pair) event key format to improve
telemetry tracking and debugging capabilities for Azure/Hyper-V
deployments.

Additional Context

The VM ID is now queried during HyperVKvpReportingHandler initialization and appended to each event key.
Changes include:

  • Query vm_id during HyperVKvpReportingHandler initialization
  • Store vm_id as instance attribute with fallback to zero-guid string
  • Update _event_key_format_parts() to include vm_id in key structure
  • Update event key format to:
    CLOUD_INIT|<incarnation>|<event_type>|<event_name>|<uuid>|<vm_id>[|subevent_index]
  • Added test_vm_id_fallback_to_zero_guid unit test to verify fallback logic.
  • Production test shows vm_id in key, where vm_id is 26bd6c2f-ecc6-4b04-9f79-e500096ee45b:
CLOUD_INIT|1762458786|finish|modules-final|b8398a61-459c-4e35-95fd-c3a099396a02|26bd6c2f-ecc6-4b04-9f79-e500096ee45b{"name":"modules-final","type":"finish","ts":"2025-11-06T19:53:30.941724+00:00","result":"SUCCESS","msg":"running modules for final"}

Merge Type

  • Squash merge using "Proposed Commit Message"

@peytonr18 peytonr18 marked this pull request as ready for review November 6, 2025 19:28
"Query for VM ID returned empty. Using zero-guid."
)
vm_id = self.ZERO_GUID

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also log the event where query for vm id was successful?

)

try:
from cloudinit.sources.azure.identity import query_vm_id
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this done late to avoid circular imports?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that was exactly why - I kept getting an error message about that. Let me know if there is a better way to avoid that circular import!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally a circular import error indicates a lack of clear hierarchy in the code. The reporting code is currently not coupled to any particular cloud, but after this change that would no longer be true.

I haven't put much thought into it, but since query_vm_id is currently not used anywhere it could just get relocated to this module.

…rder

Relocate query_vm_id() and helper functions from azure.identity to
reporting.handlers to eliminate circular import. Also fix event key format
to place vm_id before uuid in order to prevent breaking RdAgent.
@peytonr18 peytonr18 force-pushed the probertson-kvp-vm-id branch from 5e5a253 to 7b66c56 Compare November 18, 2025 01:28
@peytonr18
Copy link
Author

A request was made outside of this PR to re-order uuid and vm_id to ensure RdAgent can distinguish the key, which is the reason for the change in the most recent commit.

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.

4 participants