2 Replies Latest reply on May 3, 2018 7:15 PM by kcross

    VROps API:  Mapping from a statkey instance to its resource

    kcross Lurker

      Hi,

       

      I'm attempting to use the API to extract some monitoring data about VM's.  I'm interested in getting the allocated space in a datastore for each VM.

       

      I can get the required stat for each datastore by first listing the statkeys for the VM, then running the query below for each statkey that matches config|hardware:*|disk_Space

       

      suite-api/api/resources/stats/query

       

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <ops:stat-query 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:resourceId>***</ops:resourceId>
          <ops:statKey>config|hardware:3351|disk_Space</ops:statKey>
          <ops:rollUpType>AVG</ops:rollUpType>
          <ops:intervalType>DAYS</ops:intervalType>
          <ops:intervalQuantifier>4</ops:intervalQuantifier>
          <ops:dt>false</ops:dt>
          <ops:metrics>false</ops:metrics>
          <ops:currentOnly>false</ops:currentOnly>
          <ops:begin>1515369600000</ops:begin>
          <ops:end>1515624194000</ops:end>
      </ops:stat-query>
      

       

      I get a response back like this with the stats that I need:

       

      <ops:stat>
      <ops:timestamps>1515686399999</ops:timestamps>
      <ops:statKey>
      <ops:key>config|hardware:3351|disk_Space</ops:key>
      </ops:statKey>
      <ops:rollUpType>AVG</ops:rollUpType>
      <ops:intervalUnit>
      <ops:quantifier>4</ops:quantifier>
      <ops:intervalType>DAYS</ops:intervalType>
      </ops:intervalUnit>
      <ops:data>60.0</ops:data>
      </ops:stat>
      

       

      The issue I am facing is how do I resolve the statkey with instance, eg 3351 back to the datastore resource, or even just its name?  This happens in the UI, but I cannot figure out where the reference is