So with this next post I wanted to help explain / break down how to use the suite-api to extract stats, alarms and properties. I already provide a script which does the stats extract (stats on steroids) but I thought some of you might be interested to understand how it works.
Lets start off simple…
Where to find the API and Documentation? —-> https://yourvRopsServer/suite-api
Now you want to extract metrics from vRops, you first need to determine what the ResourceKindKey is and which metrics are available for that object
Where to find the ResourceKindKeys —-> https://yourvRopsServer/suite-api/api/adapterkinds
How to lookup objects in vRops by name and obtain the resourceID (identifier) —-> https://yourvRopsServer/suite-api/api/resources?resourceKind=$resourceKindKey&name=$vRopsObjName
Make sure you specify the type of object you are looking up by using resourceKind=, this is very important if you have multiple resources with the same name (VirtualMachines, End Point Operations, etc… )
As you can see in the 1st example the call only returned one result for the VirtualMachine, but in the 2nd it returned three one for the Virtual Machine and two others related the End Point Operations agent.
So by this point you are all like… this is nice and dandy… but GET TO THE METRIC EXTRACTION PART!!
Which metrics can I extract for the desired resourceKind? —-> https://yourvRopsServer/suite-api/api/adapterkinds/VMWARE/resourcekinds/VirtualMachine/statkeys
The following API call will list all the metrics for the VirtualMachine resourceKind for the adapterkind VMWARE
Below is an example of 2 of the 100’s of metrics for the VirtualMachine resourceKind.
alright.. now we know how to search for the object and which stat keys exist… lets put it together to pull out data!
Using the desired metric keys and the resourceId extracted in the previous example we can construct the call to extract metrics between date/time X and Y… we just need to specify some additional parameters!
intervalType: Interval type requested by the user (e.g: Days, Weeks, Months etc.)
rollUpType: Rollup Type requested by the user (e.g.: AVG, MIN, MAX etc.)
begin: start date in epoc time (milliseconds)
end: end date in epoc time (milliseconds)
The example below will extract several statkeys for a single server.
If you want to do this for multiple servers just add additional resourceId’s to the URL
cool so now we know how to extract stats… lets get to the
Extracting all the Alerts from a Resource is just a simple API call —–> https://yourvRopsServer/suite-api/api/alerts?resourceId=ResourceID
See simple!! what about all the properties you ask?!?!?
Extracting all the Properties from a Resource is just another simple API call —-> https://yourvRopsServer/suite-api/api/resources/ResourceID/properties
Hopefully you found this helpful.
hi , this is for vm’s but for clusters?
i been trying for get monthly stats from a cluster but only get one day of data.
When i put begin=.. and end:… i only get this:
i am running this:
any hint will be very welcome!
ok , already figure out, the date is epoch in MILLISECONDS.
cool glad you worked it out, I was just about to reply 🙂
Thanks for the excellent post – though a few years old, still relevant for us newbies!
I’m having a problem with a similar method that you might be able to comment on and I can surely use the help!
Instead of using GET api/api/resources/ResourceID/properties to get property information, I used POST api/resources/properties/latest/query method and gave it an array of resourceIDs and an array of propertyKeys to retrieve multiple (and specific) properties for a set of resources in one query instead of calling the individual GET for each resource ID.
This method does retrieve data but I’ve just discovered that it is very inconsistent in retrieving data for ALL the resource ids submitted. Tried 5 queries for the same set of 10 resource ids with just 3 property keys this morning and each test returned different results:
Test 1 – 3 property fields returned for just 8 of the requested resource ids
Test 2 – 3 property fields returned for only 2 of the requested resource ids
Test 3 – 3 property fields returned for only 2 of the requested resource ids (didn’t check to see if same 2 as Test 2)
Test 4 – 3 property fields returned for 8 of the requested resource ids
Test 5 – 3 property fields returned for just 7 of the requested resource ids
Behavior is like there is a timeout somewhere that is expiring and giving only the data it has retrieved so far. Any ideas on how I can troubleshoot and solve this issue? I would like to have the API consistently replying with the requested property fields for all resource Id submitted. Further, I’d like to scale this up to a larger array of resource ids (eg. 100)
Thanks for the comment, sorry for the super slow reply but the blog has taken a back seat to life unfortunately.
I am becoming more active again on the blog and will do a post to answer your question.