When working with vRealize Automation, monitoring the requests tab on the tenant portal can be really usefull. Knowing when a workflow fails for a tenant and act on this as soon as possible, can raise your tenant happiness. Keeping an eye out for failed requests with one tenant is doable, although tedious. But when your vRealize Automation environment increases and you get more tenant, you will want another way to keep track of the requests.

For this reason I wrote a Python script that will get the requests per tenant and show those failed yesterday and today. The results are then shown on a webpage, as shown in thescreenshot below.

The script is still a work in progress, but I wanted to share the initial piece of the code. There are actually 3 files used, one being the Python script en two HTML files.

Python script:

As with any python script we start loading the modules and at the bottom of the script we got the index function with the webserver information. Besides those basics there are 4 functions defined:

  1. GetTokenTenant: When making use of the vRealize Automation API you have to request a bearer token. You get this token when you use the right credentials for the specific tenant. The bearer token then allows you to execute API calls for that tenant.
  2. GetRequests: Gets the requests for the tenant and by using a filter we get only the failed ones. And since we want those failed in the last 2 days we sort them in descending order.
  3. DateTimeFormat: The default date description isn’t usefull for our purpose so this function will make it usefull for us.
  4. ExtractTenantRef: The returned object from for the failed requests hold a lot of information. This includes the tenant name aswell, but this in itself is a object to, so I created this small function to retreive the tenant name.

Render.html

The render.html uses the information retreived by the python script and makes it presentable. The style of the page, including the header are footer are all predefined with HTML. The table with actual information is created by a “for each” loop, breaking out to the python script functions 3 and 4.

Base.html

Some more layout stuff is being set by the base.html. This file also sets the refresh interval of the site at 300 seconds. So each 5 minutes you get the latest information about possible failed requests.

As mentioned the script isn’t complete yet. For one I want to add a function that will get all tenants automatically, instead of using a static array. Also I want to see if there is an optimized way of processing the “datetimeformat” function.

If you think this script is usefull or have any suggestions or comments, please feel free to share them below 🙂


Other articles in the series vRealize Automation: