vRealize Operations

Adding Custom Metrics and Properties to vRealize Operations Objects with the REST API

This blog post was written by Thomas Kopton: 

Thomas Kopton is a Senior Consultant at VMware PSO based in CEMEA specializing in SDDC Management solutions like vRealize Operations, Log Insight, Network Insight etc.  He has been with VMware since 2016 and worked in the IT industry for over 20 years.

Even if vRealize Operations, together with its rich Management Pack ecosystem, provides a huge number of metrics and properties for a variety of objects, there is sometimes that one requirement which cannot be met because of missing metric or property types for a given object.

Maybe you need to store an internal tracking number with each of your ESXi hosts or maybe you need to add a custom metric reflecting the speed and status of the fans inside your hosts.

In this blog post, I will give you an overview of how to use the vROps REST API to add new custom metrics and properties to existing objects.

How to collect or estimate values for such new metrics or properties (e.g. internal tracking numbers or fan status) is not the objective of this post.

Preparing the Postman environment


Postman client is one of the most popular and easy to use REST API clients and I will be using Postman to showcase all examples in this blog post. If you are not familiar with Postman, I highly recommend the Postman Learning Center to gain some experience with this tool. In an upcoming blog post I will explain how to accomplish the same using vRealize Orchestrator. So, stay tuned.

To be more flexible and quickly change between various vROps instances, Postman has a concept of environments to hold variables such as FQDNs, authentication information or other information used in REST calls. This way it is possible to have all information related to a certain environment in on place. My test environment looks like this:

Once created and selected, these variables can be used in REST calls, here an example of a vROps REST call to retrieve all adapter instances:

In this example I used “Basic Auth” but this will change in the subsequent examples.

Authenticating to vROps


Even if “Basic Auth” is easy to use, VMware recommends using token-based authentication, thus first step is to acquire a token. This will be done using the following API call, description of all available methods can be found on every vROps instance, simply navigate to https://YourvROpsInstance/suite-api/docs/rest/index.html:

Note: to show the samples, your browser needs internet access.

We need to make a POST call with a body containing credentials and as response we will receive the token, which will be used later on without any additional authentication.

Now we have everything we need to work with the vROps REST API:

  • Use case (add metric/property to an existing object)
  • Token (for the authentication)
  • API documentation (to find the right methods)
  • Postman (to do the work)

Finding the object ID


If we want to add any information to an object in vROps, we need its internal ID. The easiest way to obtain that ID is to navigate to that particular object in the vROps UI and locating the ID in the URL. Let’s assume we would like to add our custom “Tracking Number” as a new property to an ESXi host. We navigate to that host and copy the ID from the URL. Of course, there is also a REST API call to retrieve this kind of information. GUI-approach first:

Now using the REST API and this example shows you how to user the token (the Authorization is set to “No Auth”) to authorize and how to use request parameters to narrow down your search:


Adding custom property to vROps object


Finally, we can add our shiny new property to the object. Let our property be:

TrackingID = 1337

Which will be always a number, this is important as we are defining the type of the property while pushing the first value. The API call to do this:

As you can see, we can push multiple new properties with multiple values in one invocation of the REST call.

Please notice the difference in the type of the array used for the actual values.


  "property-content" : [ {

    "statKey" : "system|availability",

    "timestamps" : [ 1119844280663, 1119844280693, 1119844280713 ],

    "values" : [ "UP", "UP", "DOWN" ],

    "others" : [ ],

    "otherAttributes" : { }

    }, {

    "statKey" : "config|num|processes",

    "timestamps" : [ 1119844280663, 1119844280693, 1119844280713, 1119844280718 ],

    "data" : [ 93.0, 95.0, 97.0, 99.0 ],

    "others" : [ ],

    "otherAttributes" : { }

  } ]


“values” stands for string data type and “data” stands for float, never mix up values for one particular property, this will make vROps try to convert between string and float resulting in unpredicted behavior.

So. Let’s push our new property as number. For the timestamp value (Epoch time) and the ObjectID you can use the “Pre-request Script” functionality in Postman:

The property itself id described in the body and if everything worked out you will get 200 as response:

And here we see our new custom property in the GUI:


Adding custom metrics to vROps object


Adding custom metrics is as easy as adding properties. As mentioned, do not mix up strings and numbers in one metric, stick to what you defined with the first invocation of the call.

Let us push two new custom metrics, this time one string and one number:

Fan01Speed = 15.00

Fan01Status = “on”

And this is what you see in the GUI:

In upcoming post, I will demonstrate how to create custom objects using RSEST API via Postman and vRO.






16 comments have been added so far

    1. They will behave as any other time-series metric or property, i.e. a “snapshot in time” recording the value of the metric or property as it was. You can easily add more measurements for the same metric, using the same API calls Thomas provides above.

      1. Are there any references on how one would create custom metrics that are gathered dynamically/recurrently or how to fetch actual real-time system properties?

        1. You could use PowerCLI for this, I’m sure. Or any number of scripting solutions and schedule the scripts to run on a regular basis.

          1. Would the mechanism be that you would schedule and run this script on the monitored host/object and use the REST API to push the datapoints to vROPS or could you somehow plug these into the endpoint agent, or other mechanism, to run the script and collect the data for you?

          2. Windows Scheduler or crontab, depending on the host OS. In vROps 8.0 the Application Monitoring will support a custom script monitor which will run a script on a guest every 5 minutes so you could leverage that. 8.0 releases later this year.

  1. As pointed out in the beginning “How to collect or estimate values for such new metrics or properties (e.g. internal tracking numbers or fan status) is not the objective of this post.”
    If possible, could you please point us to some article that explains the collection part.
    Thank you

    1. It is really dependent on the metrics being collected and where you are collecting them from. For example, if you are pulling from some other monitoring tool like a network switch element manager, you’ll need to follow the API documentation for that tool to see how to get the metrics out, then you can use the example in this blog to push them into vROps.

  2. Does this require any certain licensing level for vRops ?

    I have Advanced, and followed all this on 8.1 and get a return code of 200 when doing the post.

    But no metrics ever show up in the GUI.

    1. Advanced is fine. It can take some time for the metrics to appear in the UI, you can check to see if they are in vROps by making an API call to retrieve them.

      1. I actually opened a case with VMware on this, I am able to make the API calls and get success when doing so, I also am able to retrieve the custom stats from the API. But nothing ever shows up in the GUI. Have you tried this on 8.1 yet? latest build. That’s what I am on and having issues with.

    2. Joining the question,
      I have successfully created the metric but the value never populates on the metric.
      when i query the metric using restapi there is no value at all .

Leave a Reply

Your email address will not be published. Required fields are marked *