Tuesday, October 25, 2016

VMware vROps - Exposing and Reporting on VM Custom Profiles with API and Super Metrics

Since the introduction of Custom Profiles in vROps 6.1, VMware has given customers the ability to define their own custom VM sizes for capacity planning purposes. This is a very handy feature when performing capacity analysis 
using the canned Analysis > Capacity Remaining dashboard on the vSphere Cluster level. However, there is no way to access these custom profile metrics through any of the metric pickers so they cannot be added to custom dashboards or reports. API and Super Metrics to the rescue. In this post we will cover how to access and expose the custom profile metrics to the GUI so they can be easily leveraged throughout the product's various visual elements. I had many customers ask for this in the past so figured it's time to let the cat out of the bag and let the world know.

Quick Steps
If you are already familiar with the vROps API and Super Metric concepts, here is a quick summary of the steps needed to accomplish this task. If not, read on for detailed step-by-step instructions with screenshots.
  1. Create a Custom Profile
  2. Find the Metric Key of the new Custom Profile via the API
  3. Create and enable a Super Metric using the Metric Key from step 2
  4. Wait until the capacity calculations are performed (once every 24h) to see the new Super Metric. (I provided a cheat step in details to work around this delay.)
And there you have it, not too bad. 

Add New Custom Profile
(If you know how to add new custom profiles already then skip to Get Custom Profile Metric Key using API section.)
First we need to find define a Custom Profile that fits our organization standard size. There are two way of doing this. You can just click the great big plus sign under What Will Fit next to the predefined sizes on the Analysis > Capacity Remaining dashboard at the vSphere Cluster level.


Alternatively, it can be added from Content > Custom Profiles.


Regardless of which method you use it will launch the same Add New Profile wizard. Specify the Profile Name, Filter Model(s), and your resource sizes for CPU, Memory, Disk, and IO if enabled in your Policies.


Optionally, you can prefill the resource sizes by Importing Metric Values, click Populate metrics from... and select a VM you would like to use for the base values.


Once the resources are populated, click OK to save the new profile. You can create multiple profiles depending on how many standard sizes your organization wants to use. 


After the new profile is created it will appear as one of the What Will Fit options.


NOTE: Keep in mind that your # Virtual Machine will probably have a ? mark instead right after you create a new Custom Profile. This is because capacity is calculated once every 24 hours at night. To force the calculation to happen in a more reasonable amount of time you can edit the Provisioning Time Buffer setting (add/subtract a day) in the Policy used by the vSphere Cluster in question. This will force new Capacity figures to be calculated including the new Custom Profile. You may have to wait 10 to 30 minutes to see results depending on the size of your environment.



Now that we have the basics out of the way, let's move on to the real meat of this post. As discussed in the opening paragraph these cute little Custom Profiles do not show up in other places in the GUI. This is somewhat inconvenient if you would like to create a report or a dashboard that uses the custom VM sizes you just worked so hard to define. Do not despair any longer.



Get Custom Profile Metric Key using API
OK then, let's find our new Custom Profile's Metric Key using the API. This is a two step process. First we need to get an Identifier for one of our vSphere Clusters which we can then use to enumerate all metrics and get the Metric Key of our Custom Profile. To get the list of all vSphere Clusters monitored by vROps just open a Web Browser and go to the following URL. Replace <vROpsFQDNorIP> with your vROps name or IP.
https://<vROpsFQDNorIP>/suite-api/api/adapterkinds/VMWARE/resourcekinds/CLUSTERCOMPUTERESOURCE/resources
You will be prompted to login, use your admin credentials.



Once authenticated you will get a listing of all vSphere Clusters. Just highlight and copy hex number in the Identifier field for the first vSphere Cluster listed, it does not matter which cluster the ID is for. Only copy the number, no quotes, etc.



With the vSphere Cluster identifier safely stowed away in your computer's clipboard, edit the browser URL to make it look like this.
https://<vROpsFQDNorIP>/suite-api/api/resources/<vSphereClusterIdentifier>/stats/latest
Replace <vSphereClusterIdentifier> with the ID you saved in the clipboard from your vROps System in the previous step and hit enter. (Keep in mind that all identifiers are unique to each vROps instance so the ID you see in my screenshots will not work for you.)



If you did everything right you should get a listing of all metrics and their current values for the cluster ID you specified.

Now use the browser's find feature and search for the name of the Custom Profile you created at the beginning of this post, in my case it was Size X.

NOTE: You will find few metrics that will match your profile name, there will be one for CPU, Memory, and Disk. However, the one we need is summary. You could of course create a super metrics for all of these if you're so inclined. I'll just stick with summary because that's the important one for this example and you can just rinse and repeat the same steps to create more super metrics.



Now that we found our Metric Key let's copy summary:Size X|capacityRemainingUsingConsumers into our clipboard, we'll need it to create our super metric in the next section. 

NOTE: You can also use a REST API Client to do this instead of a web browser. I typically use Advanced REST Client or Postman, but for simplicity I decided to opt for the browser since I was not using the API to post anything.

I'm not going to get into how to use the vROps Rest API in this post because this was not the objective. This is just a quick and dirty to get us what we need to make capacity planning easier, but if you want to learn more see vROps API documentation at: https://<vROpsFQDNorIP>/suite-api/docs/rest/index.html

Put Custom Profile Metric Key into a Super Metric
With our Custom Profile Metric Key we can now go on and create a Super Metric that will fetch the value from the database and allow us to access it via various Metric Pickers in the GUI opening up new dashboard and report possibilities. 

Go to Content > Super Metrics and click Add New Super Metric.



In the Manage Super Metric wizard specify the Name, I'm going to call mine Size X Summary so it references my Custom Profile. Then in the Object Type section we filter for "Cluster" and select Cluster Compute Resource from the list. (Remember that in vROps Cluster Compute Resource = vSphere Cluster.) Now, in the Metrics section we filter for Size, but the results do not show Size X Custom Profile under the Summary node.



This where our Custom Profile Metric Key will become handy. In the formula field highlighted by the red dotted box type in or paste the following: ${this, metric=} and paste the Custom Profile Metric Key ,right after the equals sign, you copied from the API in the previous section. The whole things should look something like this:
${this, metric=summary:Size X|capacityRemainingUsingConsumers}
You will have to replace Size X with your Custom Profile name.


With our formula in place click the Show Formula Description button to check syntax and validate it. If it works, the wizard will return a description below the formula  that looks something like this: This Resource: summary:Size X|capacityRemainingUsingConsumers



With a valid formula we can preview our super metric values by clicking the Visualize Super Metric button.



This will change bottom section of the Super Metric wizard from displaying Metrics and Attribute Types to a Metric Chart. In order to preview the values Select Cluster Compute Resource under Object Types, then click one of the vSphere Cluster names on the left under the Objects. And there you have it, 28, which is the same as what we saw earlier when we created the Custom Profile. Click Save to save your new super metric.

NOTE: If the visualization does not display a chart, use the Date Range to change it from the default Last 6 Hours to at least 24. This is because as mentioned earlier the capacity calculations are only performed once per day.



Now that we have the super metric created we need to assign it to an Object Type and enable its data collection in the Policy,

Select the Super Metric we just create and in the lower part of the screen click on Object Types and then click Add Object Type. On the Select Object Type pop-up click the drop-down arrow and expand vCenter Adapter, then select Cluster Compute Resource and click Select.



We should now have both the super metric and its object type defined.



One last thing we need to do it to go to our Policies and enable this super metric so it can start collecting data and become accessible via Metric Picker in the GUI.

Click on Administration > Policies > Policy Library. Select the policy that's used by your vSphere Clusters and the Edit Selected Policy button.



In the Policy wizard click on Collected Metrics and Properties tab. In the Attribute filter type the name the Super Metric you created for your Custom Profile. Select the Super metric that corresponds to the Cluster Compute Resource Object Type and click the drop-down arrow in the State Column. Select Local and click Save. This enabled the Super Metric, initiate data collection, and make the Super Metric accessible.



Again, just like with the API I'm not going to get into the logic behind creating various types of Super Metric here as that's an extensive topic for another post. If you want to learn more about Super Metric for now please read this White Paper: Creating and Applying Super Metrics in a vSphere Environment (PDF)

Use the Custom Profile
Woo Hoo! Now for the victory lap let's create a quick dashboard with some views using our new custom profile based super metric. As promised we can now see our Custom Profile as a Super Metric for the Cluster Compute Resource.



And here an example of a simple dashboard using our new Super Metric. The What Will Fit into the Select vSphere Cluster is a List View that can also be dropped into a capacity Report.


Don't forget that our new Super Metric or even the base metric can always be used in an XML Interaction file despite not showing up in the GUI by default. Here is the example dashboard,



NOTE: If you like the new Scoreboard visuals, check out my blog post on what's new in vROps 6.3 where I take a deeper walk-through all of the new features I discovered beyond what was in the release announcement. A closer look at what's new in vROps 6.3.

Here is an XML Interaction File example used for the Scoreboard widget.

<?xml version="1.0" encoding="UTF-8"?>
<AdapterKinds>
    <AdapterKind adapterKindKey="VMWARE">
        <ResourceKind resourceKindKey="ClusterComputeResource">
            <Metric attrkey="summary|capacityRemainingUsingConsumers_large" label="Large VMs" unit="" yellow="" orange="" red=""/>
            <Metric attrkey="summary|capacityRemainingUsingConsumers_medium" label="Medium VMs" unit="" yellow="" orange="" red=""/>
            <Metric attrkey="summary|capacityRemainingUsingConsumers_small" label="Small VMs" unit="" yellow="" orange="" red=""/>
            <Metric attrkey="summary|capacityRemainingUsingConsumers_average" label="Average VMs" unit="" yellow="" orange="" red=""/>
            <Metric attrkey="summary:Size X|capacityRemainingUsingConsumers" label="Size X VMs" unit="" yellow="" orange="" red=""/>
        </ResourceKind>
    </AdapterKind>
</AdapterKinds>

Enjoy chaps! It could be done. I hope this gets you over the hump and on to creating some awesome custom dashboards and reports using the new custom profile super metrics.

For more information about vROps, see the following resources:

vROps Extensibility Options:
You can extend vROps functionality by installing additional management packs:
VMware Management Packs include options for vRA, NSX, vRO, Log Insight, AWS, etc.
Blue Medora Management Packs include options for NetApp, Oracle, SAP, UCS, Citrix, etc.

Books:
VMware Performance and Capacity Management - Second Edition by Iwan 'e1' Rahabok
VMware vRealize Operations Managers Essentials by Matthew Steiner
Mastering vRealize Operations Manager by Scott Norris
VMware vRealize Operations Manager Capacity and Performance Management by Iwan 'e1' Rahabok

Official VMware:

VMware Professional Services
Official vROps Documentation
VMware Operations Management White Papers
vROps product page

Blogs:
VMignite by Lan Nguyen
vXpress by @Sunny_Dua 
virtual red dot by @e1_ang
Virtualise Me by @auScottNorris
Elastic Sky Labs by @JAGaudreau

No comments:

Post a Comment