Question

How to get VM/Host/Cluster/etc. statistics from API in bulk?

  • 31 October 2019
  • 4 replies
  • 4163 views

Hi,

 

is there a way how to get VM/Host/Cluster/etc. statistics from API in bulk?

 

We know about the /stats endpoints, but those only allow to get stats for single entity, so in case there are hundreds of VMs in cluster that would mean hundreds of separate requests to API. We don't really want to put lot of strain on the cluster just by polling stats. Our default polling interval is several minutes, so using projection=stats doesn't really work for us (as I believe it provides current value) and we'd need to know the stats for the time interval between our polls.

 

Thanks so much for your time.

 

Best regards,

Marek


4 replies

Userlevel 3
Badge +4

Hi Marek,

thank you for posting your question. To better understand your question,  have two parts to your question:

  1. stats for Multiple entities in a single rest call
  2. Collecting stats between the polling intervals (are you going to co-relate them between the intervals)?

have you checked our nutanix.dev portal, which has examples for collecting stats via rest api. incase you haven’t already, here’s the link :
 

https://www.nutanix.dev/2019/01/16/getting-performance-stats-with-the-nutanix-api-v2-0/

https://www.nutanix.dev/2019/09/23/getting-vm-performance-metrics-via-api/

Best regards

Hi Mutahir,
 

Thank you for the fast reaction.

I have checked everything what is possible with no success. Yes we need to have stats for an array of multiple entities as bulk in one response. Ideally we would like to have all stats in one response without need to specify them one by one.

Ad 1) 
Currently the API V1 provides only e.g. VMs stats in this way:

https://{{cluster_ip}}:9440/PrismGateway/services/rest/v1/vms/{{vm_uuid}}/stats/?metrics={{vm_metric}}&startTimeInUsecs={{startTimeInUsecs}}

Where {{vm_uuid}} is just one particular UUID identifier.

But we need to get stats for all entities as bulk with one request and one response without need to specify them. At least we need to be able to specify an array of entities in one request to get one response containing the bulk of stats.

Ad 2 )

We need to have stats between the polling intervals e.g. due to a detection of anomalies and unwanted states (peaks and drops). The Nutanix API already provides the granularity that we need but only with one request per entity which causes big performance overhead.

 

Best regards
 

Userlevel 5
Badge +5

@MarekSWI 

There may a better solution out there but what I had to do in a similar situation was to build an array of UUIDs first, then query stats for each of UUIDs in the array in a loop while recording stats into another array.

Does that make sense?

 

Userlevel 4
Badge +5

@MarekSWI  

Just a random idea, we can try to use multi-threading either in python or JS to invoke multiple API calls so the execution time decreases. 
 

Reply