I can authenticate fine and get a list of the resources I want to get stats for, in the particular case, 3par resources.
Looking at https://MyvROpsServer/suite-api/docs/rest/index.html, it looks like I need to make a request to https://MyvROpsServer//suite-api/api/resources/{$ResourceID}/stats/query,
but this gives me a "Invoke-RestMethod : The remote server returned an error: (400) Bad Request." error.
Here is my code:
$Headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Headers.Add("Accept", "$Type")
$Headers.Add("X-vRealizeOps-API-use-unsupported", 'true')
$Type = "application/xml;charset=utf-8"
$ResourcesURL = $BaseURL + "resources/$ResourceID/stats/query"
$Stats = Invoke-RestMethod -Method POST -uri $ResourcesURL -Credential $cred -ContentType $Type -Headers $Headers
So in short, does anyone know which REST API command would give me the equivalent of PowerCLI's Get-OMStat?
Or perhaps know of a place that has good examples?
I have also been trying to format some XML to send in the body, but again, without some useful examples, I haven't been able to get that to work.
Hi Panzerbjorn!!
Iḿ also interested in your question, and I will try to help you:
You can download from vmware sample code a "postman vrops collection" and there is a web explaining how to configure it. (Do your google research).
Next you have to query to vrops for resourceid of your object, you will find something like this:
Once you got it, do your query with this identifier, setting the metric you need, and voila!:
Good luck!!
interested in this question as well. Let us know how you go
Hi, thanks for your reply. Unfortunately I'm not really interested in doing this via a GUI as we would like this to be automated.
I have seen several references to Postman in their documentation, and I guess VMware just really likes manual work rather than automation... -__-
imo vmware probably arent very interested for customers getting data out of vrops.
Are you sending a body with your request? I don't see one in the Powershell sample you provided. You need to send a body with your POST request that includes the details like begin/end time. There's an example in the docs or this article: Extracting Data From vRealize Operations with the REST APIs - VMware Cloud Management
Postman is a useful tool for exploring and testing APIs. Once you figure out which parameters you need in Postman you can transfer that into your language of choice. Here are some different examples using Powershell.
https://virtualcloudit.net/2017/06/02/vrops-extract-temperature-metric-data-via-the-api/
Help using Suite-API - getStatsOfResourcesCSV with Powershell Invoke-RestMethod