24 Feb 2025
03:04 PM
- last edited on
25 Feb 2025
10:53 AM
by
MaciejNeumann
Hi Community,
Is it possible to access the cloud VM running status from DQL?
In the integration there is a staus field. This seems to be correct even if for some reason the platform-level metrics are not showing correctly. I would like to access this status with DQL to use in a dashboard that I'm building.
The dt.entity.azure_vm does not have such dimension, it is also not a metric. What is it?
I would appreciate any help.
24 Feb 2025 06:34 PM
Use the lifetime field to determine if the lifetime[end] value is some distance in the past.
Example DQL for Azure VMs whose lifetime[end] is more than one hour in the past
fetch dt.entity.azure_vm
| fieldsAdd lifetime[end]
| filter lifetime[end] < now() - 1h
25 Feb 2025 11:51 AM
Hi Marco,
Thank you for the suggestion.
I tried this approach, but if applied with long enough time window it will mix stopped VMs with the ones that no longer exist. It seems that it's based exclusively on the last metric datapoint available to dynatrace for the given entity. I mentioned in my question that I observed a correct status (running) in Dynatrace even if the VM metrics were not available.
At the same time I observed a message like this in the activeGate log
<vtopology.provider>, VirtualMachineEntity] Received null or empty PowerState for VirtualMachine: VirtualMachineEntity{type=AZURE_VM, entityId=-524919XXXXXX, name=XXXX-XX-XX-01, resourceId=....
It suggests that Dynatrace makes API calls to get power status of the VMs
What I'm interested in is the power status. So as long as the VM exists it should be either running or stopped.
Then if a VM is deleted the value would be null