Unleashing the Power of VMware Technology

Getting Started with Jira and Aria Operations

Posted by:

|

On:

|

I am currently working with a customer who is trying to send information from Aria Operations into Jira. There is no native integration with Jira so the two most evident options are (1) using a web hook to push information out of Aria Ops, or (2) using APIs to pull information from Aria Ops.

I will start with web hooks because that is the most straightforward:

Webhooks in Aria Ops:

  1. To use web hooks, navigate to Configure > Alerts > Notifications
  2. Press Add at the top.
  3. You will have to move through the tabs by adding a name and then defining the alert criteria. 
  4. Once you are on the third tab, this is where you can set the Outbound method:

5. Select Webhook Notification Plugin.

6. You will have to create a new web hook instance by pressing the + sign.

Note: You can access the Outbound Methods directly by navigating to Configure > Alerts > Outbound Settings

Brock Peterson has a great blog on this (using web hooks for slack): https://www.brockpeterson.com/post/send-vmware-aria-operations-alerts-to-slack

Api in Aria Ops:

Leveraging APIs is another option to pull data into Jira, however there is a bit more configuration that is required.

Firstly, I would encourage people to read through these links to get a sense of how the APIs work and to become aware of some of the “gotchas”

Aria Ops Official Documentation: https://docs.vmware.com/en/VMware-Aria-Operations/SaaS/API-Programming-Operations/GUID-C27B4402-56DF-45D6-8813-EC2617D24407.html

Using Powershell: https://virtualg.uk/getting-started-with-the-vrops-rest-api/

Using Postman: https://angrysysops.com/2022/02/25/vrops-api-first-steps-what-to-do-what-to-use/

To access the Swagger based APIs, append your Aria Ops on perm server url with “/suite-api/doc/swagger-ui.html” or your SaaS server with “/vrops-cloud/suite-api/doc/swagger-ui.html

Once you have done this, you will realize that one of the trickiest things that you have to do is retrieve a token. 

Postman:

The most straightforward example uses Postman:

If you are following the above documentation, note that the instructions seem to imply that you need to input the RAW json code as follows:

   {

       “username”: “{{username}}”,

       “authSource”: “{{source}}”,

       “password”: “{{password}}”

   }

However, it is important to note that “authSource” is optional. Therefore my code was simply as follows:

It is worth noting that the token will be an alpha numeric string and also contains an expiration date.

Python Code:

Another more involved approach would be to create a python script that regularly refreshes the API token.  A peer of mine, Alonso Trejo Mora, wrote the following script which can be uploaded in an IDE to accomplish this.

His script is as follows:

import requests
import os # Not a Pip dependency. Built into Python.
import json # Not a Pip dependency. Built into Python.




# Use your Refresh Token to obtain a temporary Bearer Token
# source: https://developer.vmware.com/apis/vrealize-operations/vrealize-operations-cloud-api/latest/
def Fetch_New_Bearer_Token():
refresh_token_path_from_root = os.getcwd() + “/csp-monitoring-refreshToken.txt”

with open(refresh_token_path_from_root, ‘r’) as f:
refresh_token = f.read()

requestUrl = “https://console.cloud.vmware.com
extension = “/csp/gateway/am/api/auth/api-tokens/authorize”
headers = { ‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/x-www-form-urlencoded’}
data = f”refresh_token={refresh_token}”

response = requests.post(requestUrl+extension, headers=headers, data=data)
print(response.status_code)
if response.status_code != 200:
print(f’ERROR: Status code {response.status_code}’)
exit(1)

jsonResponse = response.json()

accessToken = jsonResponse[‘access_token’]

# Update the Bearer Token file with the new Bearer Token.
access_token_path_from_root = os.getcwd() + “/csp-monitoring-accessToken.txt”

with open(access_token_path_from_root, ‘w’) as f:
f.truncate(0)
f.write(accessToken)

if __name__ == ‘__main__’:
Fetch_New_Bearer_Token()

https://www.mgmt.cloud.vmware.com/vrops-cloud/suite-api/

Notes: A few things that you will need to know in order to get this code to work. I found that i needed to upload Pylance to my IDE to import the “request” package

Additionally, you will need to make a .txt file named “csp-monitoring-refreshToken.txt” and have it in the same file repo as the above code. The csp-monitoring-refreshToken.txt file will need to contain the alpha numeric token that you pull from a Cloud Services Portal.

You can read about how to pull the token string from here: https://docs.vmware.com/en/VMware-Cloud-services/services/Using-VMware-Cloud-Services/GUID-E2A3B1C1-E9AD-4B00-A6B6-88D31FCDDF7C.html

When you run this code is will take the refresh token and output a CSP access token string in the .txt file: “csp-monitoring-accessToken.txt”

Posted by

in