Importing data with a REST API
What if there is information we would like to import into vRealize Operations but there is no solution available? This is fine as vRealize Operations supports multiple ways to import any data we like, but it will require some scripting if it's a regular import.
Prior to vRealize Operations 6.0 in 5.x, we had the HTTP POST adapter and the TEXT adapter. Both could import data into vCenter Operations Manager 5.x. In vRealize Operations 6.6, we still have access to the HTTP POST adapter; this adapter has remained unchanged from vCenter Operations Manager 5.x for legacy support, and any current scripts importing data that is configured should still work using this adapter.
The new and preferred way to import our own data is through the new vRealize Operations REST API. This is a highly-functional API. Most GUI tasks can also be done through the API if required. The vRealize Operations nodes we have deployed all have a detailed REST guide built in; this can be found by navigating to https://<vRealizeOperations_FQDN/IP>/suite-api/docs/rest/index.html. Here we can find sample code and information on all the rest functions. If you currently don't have anything importing via the HTTP POST adapter, it would be highly recommended that anything new be done through the new REST API, or as its commonly referred to, the Suite API solution.
The Suite API is the only officially supported API for vRealize Operations. As you might have seen in the previous screenshot, the Suite API is broken down into two parts:
- Public API
- Internal API
In this example, we will be importing a Recommendation into vRealize Operations using the REST API:
- Open your favorite REST tool. Anything that can make standard REST calls will work, like curl in Linux or even a browser with the right plugins. In this example, I'm using Postman.
- Select POST as the method, and type the https://<vRealizeOperations_FQDN_OR_IP/suite-api/api/recommendations URL.
- Create authorization for requests by supplying a username and password for vRealize Operations
- Create an application/XML header:
- Paste the following code in the body of the request:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ops:recommendation xmlns:ops="http://webservice.vmware.com/vRealizeOpsMgr/1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ops:description>My REST imported recommendation (USR)</ops:description>
</ops:recommendation>
In Postman the request body would look similar to this:
For reference, the JSON for the above XML code would be as follows:
{
"description" : " My REST imported recommendation (USR)",
"others" : [ ],
"otherAttributes" : {
}
}
- After posting this to vRealize Operations, navigate to the Recommendations section within the UI. You should see the imported recommendation listed:
This is a very basic example of what can be achieved if there is no official solution for the data we would like to import. Most of what people want to import will be IT-related in some way, but vRealize Operations is definitely not limited to computer data; we can import data on weather, power usage, parcel deliveries, and anything we can apply relationships and metrics to.