Programmatically Push Custom Data into vCenter Operations

I’ve been doing a lot of customization with vCenter Operations Manager lately, mainly customized dashboards, and I wanted to explore ways of getting data into vCOps other than having to use a third party adapter (such as Hyperic) or make my own adapter. Enter the HTTP Post Adapter. The HTTP Post adapter comes with vCenter Operations (I believe this comes with Advanced licensing or >) allows you to pull data, but it also allows you to push data. Below I’m going to describe the method for pushing data into vCOps using the Http Post Adapter along with functions for both Powershell and Python that will allow you to programmatically push data.

Before we start with the process for using the Http Post Adapter to push data to vCOps, you might be wondering “Why would I ever do this?” Here’s a simple example:

Let’s say you have some physical servers that you want to monitor to ensure they are “up”. Maybe you have a monitoring tool to do this, but it doesn’t integrate into your vCOps user interface. Using the Http Post Adapter you CAN monitor this from the vCOps user interface. Now, you would need some sort of script to that is monitoring the server state, but you once you have that, you can take the result of that and push it into vCOps. You can then create a dashboard in vCOps (or add to existing dashboard) and monitor the state of those physical servers. So, you can create a script (Powershell or Python in this example) and set a scheduled task or cron job to run it at whatever interval you wish, and then call the functions below within that script to continuously and programmatically push the most up-to-date data into vCOps.

From what I can see you can only push numerical data to vCOps with the Http Post Adapter. Also, this is not limited to Powershell or Python. As long as you can do a standard HTTP REQUEST/POST, you can use the Http Post Adapter. Powershell and Python are the languages I am most familiar with so i’m using those for the examples.

To really drive this home let me share one more example: I recently posted a python script on how to find ‘orphaned’ virtual machines, meaning finding virtual machines that lived on a datastore but were not registered in the vCenter inventory. You can find the script here. Using the Python function below I could send the number of virtual machines found to be ‘orphaned’ and push that to vCOps. I could then have a dashboard/widget in vCOps that showed me how many virtual machines were ‘orphaned’ in the environment. This could be really useful if you have people constantly monitoring an operations type dashboard. Now, lets get to the functions before your Internet A.D.D. takes over. There are some items that must be defined and explained that you’ll need regardless of the language you use to push data via the Http Post Adapter. The interface we are going to use within the Http Post Adapter is called addGeneralMetricObservations. Within this interface are parameters that you need to specify. I’ve listed them out along with examples. I’ve left out parameters that are optional.

  • resourceName – this will be the resource name in vCOps. An example would any virtual machine. Each virtual machine has a resourceName. Whatever you want the resource to be called is what you use here.
  • adapterKindKey – this will always be set to Http Post
  • resourceKindKey – this will be the resource kind for the data you’re pushing. For example, a virtual machine is a resource kind. All resources with a resource kind of virtual machines will show up under the Virtual Machine resourceKindKey
  • resourceDescription – Enter any description you want here, but as you update the same metric you should probably use the same description
  • metricName – this is what you want the name of the metric to be. This is normally a tree structure so you you separate the top level name with the pipe ( | ). For example, the top level could be Virtual Machine and the metric itself CPU. The name would then be Virtual Machine|CPU
  • alarmLevel – this must be a value from 0-4. I don’t quite know what this is. For now just use 0
  • alarmMessage – again, not sure what this is for, you can put anything in here
  • date – this has to be formatted in milliseconds since epoch (Google this for more info)
  • values – this is what you want the value of the metric to be. In the above example of ‘orphaned’ virtual machines this would represent the numeric value. This must be numeric value
These are all the values required for the Http Post to be successful. These parameters are positional, and not by name. In the body of the POST request this is actually broken into two different lines. The first line starts with resourceName and the second lines starts with metricName


Push data into vCOps using Powershell and the Http Post Adapter

We can use Powershell to perform an HTTP Post request to vCOps using the parameters listed and the Invoke-WebRequest cmdlet. Here’s the function:

Now when you log into the custom UI of vCOps and go to Environment -> Environment Overview. Now on the left if you expand Resource Kinds you’ll see the new Resource Kind and resources we just added with the Powershell function. In this case, we created a new Resource Kind named “Valcolabs” with a new Resource named “Number of Posts” env_overview Here are the metrics in a dashboard view. dashboard_overview

Push data into vCOps using Python and the Http Post Adapter

If you’ve actually made it to the end of this post, go have a drink, you deserve it. If you have any questions or need help please don’t hesitate to reach out to me, either in the comments or @joshcoen on Twitter.

Comments 16

  1. Pingback: The Scoop – June Edition | vmnick

  2. Hi,

    I tried to run this using powershell code from my VM The code executes fine. But still i am not able to see in the resource kind. My vcops UI is Any pointers will be helpful.


      1. Post

        Sorry I missed your comment earlier this week. I’m glad to hear you got it working. Was there an issue with the code you had to change?

  3. I used the same poweshell example. Passed $custval = 15. In the metric, I am not able to see any data. But it shows health 100%. What went wrong?


    1. Post

      You can see the new resource showing up, correct?
      What is the name of the new resource you’ve created?
      What is the name of the metric you created?
      Can you post screenshots of each of the screens so I can see what you’re seeing?

  4. Hi There,

    I have had the same issue. In the metric, I am not able to see any data when I use the metric in Dashboard. Also i am not able to see in the resource kind the $reskind i created.

    Neo A

    1. Post

      Hi Neo,

      Is the metric and resource kind both showing up? If so, please post a screen shot. Also, are you continually updating the metric, or you just rant it a few times? Please post of screenshot of the metric history over the last week so I can see what the high and low values are.

  5. Pingback: VMware vCenter Operations Manager and Pure Storage Rest API | 2vcps and a Truck

  6. Pingback: XtremIO Integration with vCenter Operations » ValCo Labs

  7. I want to write a adapter to push data from external source into vcops. Is the above method you have prescribed different than writing a adapter or its the same thing? What all did you need to download(pre reqs) in order to push data as above?

    1. Post

      You don’t need to download anything to be able to push data in vROps, it’s just an endpoint that already exists. Creating a custom adapter is much more involved than what i’m doing here.


  8. Hi Jason,

    Do you know any way t o pull data form a vROps dashboard? in the example someone would have to keep pushing the data to vROps or maybe run a schedule task that pushes data every now and then, but it would be nice if you could configure the pulling directly from vROps. Also in the example I kind of lost track of the initial purpose of getting the list of orphaned VMs since it is only pushing an integer value, do you know if strings can also be pushed to vRops?

    Thank you,


  9. Pingback: How to programmatically push data in vRealize Operations Manager – Anything Virtual and Cloudy

  10. Pingback: How to programmatically push data in vRealize Operations Manager - VMware Cloud Management

  11. Pingback: How to programmatically push data in vRealize Operations Manager –

Leave a Reply to Boopalan Cancel reply

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