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… )
https://vrops.vman.ch/suite-api/api/resources?resourceKind=VirtualMachine&name=WINSRV2
https://vrops.vman.ch/suite-api/api/resources?name=WINSRV2
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!
STATS
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.
https://yourvRopsServer/suite-api/api/resources/stats?resourceId=fff51992-8d2c-4691-b916-0c7928b32fd0&rollUpType=AVG&intervalType=MINUTES&statKey=cpu|usagemhz_average&statKey=cpu|costopPct&statKey=cpu|readyPct&statKey=cpu|iowaitPct&statKey=cpu|idletimepercent&statKey=cpu|demandPct&begin=1496654376000&end=1496827176000
If you want to do this for multiple servers just add additional resourceId’s to the URL
https://yourvRopsServer/suite-api/api/resources/stats?resourceId=fff51992-8d2c-4691-b916-0c7928b32fd0&resourceId=fff51992-8d2c-4691-b916-0c7928b32fd0&rollUpType=AVG&intervalType=MINUTES&statKey=cpu|usagemhz_average&statKey=cpu|costopPct&statKey=cpu|readyPct&statKey=cpu|iowaitPct&statKey=cpu|idletimepercent&statKey=cpu|demandPct&begin=1496654376000&end=1496827176000
cool so now we know how to extract stats… lets get to the
EVENTS
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?!?!?
PROPERTIES
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.
vMan
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:
ttps://vrops/suite-api/api/resources/stats?resourceId=a24353-4490-4790-a1f5-1fa122662dbc&begin=1512158761&end=1514837161&statKey=cpu|capacity_contentionPct
any hint will be very welcome!
Martin
ok , already figure out, the date is epoch in MILLISECONDS.
cool glad you worked it out, I was just about to reply 🙂