cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Accessing Azure VM or AWS EC2 power status wwith DQL

2181
Newcomer_

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?

Screenshot 2025-02-24 at 14.55.57.png

 I would appreciate any help.

2 REPLIES 2

marco_irmer
Advisor

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

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

Featured Posts