Azure metadata "compute-name" is lost when resource-detector host.name
attribute is overwritten by other detectors #12779
Description
Describe the bug
The "Azure resource detector" stores the compute name in the host.name
attribute Ref..
The host.name
attribute is not unique to the "Azure resource detector" and can be overwritten by other detectors, for valid reasons; for instance, customer wants the FQDN representation for host.name
(see repro steps below) whereas Azure detector is setting the host.name
to the compute name (which is different).
This is all well and good until your code wants to use the original value set by Azure detector, at this point, the compute name fetched from Azure metadata is lost.
In our case, our code expects and uses the compute name to build the Azure Unique ID dimension, so it uses the host.name
attribute Ref.. , but because user has configured their resourcedetection processor to get host.name
in FQDN format , we end up with the wrong Azure Unique ID
Steps to reproduce
Use the following resourcedetection processor in your pipeline in order to get host.name
in the FQDN format
resourcedetection:
detectors: [system, azure, env]
override: true
system:
hostname_sources: [lookup]
What did you expect to see?
host.name
is getting set correctly to FQDN test-az-es.az.splunk.com
and expect that azure_resource_id azure_resource_id
is equal to (not the compute name at the end of the string)
zzzzzz-xxxx-ccc-9xxad8-xxx/east-us-2/microsoft.compute/virtualmachines/test-az-es
What did you see instead?
azure_resource_id azure_resource_id
is set to
zzzzzz-xxxx-ccc-9xxad8-xxx/east-us-2/microsoft.compute/virtualmachines/test-az-es.az.splunk.com
What version did you use?
Version: latest
What config did you use?
resourcedetection:
detectors: [system, azure, env]
override: true
system:
hostname_sources: [lookup]
Suggested Solution and other thoughts
Introduce cloud specific attributes for example cloud.host.name
and cloud.host.id
(if we want to only fix azure, then we can introduce azure.host.name
azure.host.id
) to persist the data parsed from the cloud metadata and maintain the flexibility for user to overwrite host.name
with FQDN if they wish.
Also note that this applies to other cloud providers, example AWS, GCP, but at the moment, this edge case won't impact them as I am not aware of any code using the host.name
like Azure is doing