How to Send vRealize Operations Manager Alerts into Microsoft Teams

I've seen several people talking about trying to get vROPS alerts into Microsoft Teams, so after some research I found that getting vROPS alerts into Teams can be done. There are a lot of different articles out there on how to do this. My goal with this post was to pull all the info needed to accomplish this task into one place. I will add a references section at the end of this post to be sure and give credit to all those that have done this before. I by far did not write any of the scripts used in this process.

Ok, lets get started.

First I configured the Teams side of things. In my Team I created a new channel and called it VMware Alerts.

Next to the new channel click the ... and select Connectors

When the connectors menu come up we need to configure the Incoming Webhook Connector

Basically here we need to give the connector a name, there is also a option to add a icon as shown below

Once the create button is clicked Teams will assign a unique URL to the webhook. Here is what the finished product will look like. I copied the URL into notepad. We will need it a little later in this process.

After we verify this is what, we want click done. Ok, we are finished with the Teams side.

Now for the VMware side. vRealize Operations Manager sends alert notifications as HTTP POST with a JSON body. However, most third-party solutions expect incoming webhooks to be in a proprietary format. If the receiving system lacks native support for the webhook format, a shim between them can translate the webhook format as needed. For the webhook shims here is the link to the information. https://github.com/vmw-loginsight/webhook-shims

First things first. We need to build a Photon OS virtual appliance to house all the shims. Here is a link to download Photon OS. For this I used Photon OS 2.0.

https://github.com/vmware/photon/wiki/Downloading-Photon-OS

I think we all know how to deploy the OVA, so I will not go through all that here. Only thing to do in the install is give the VM a name. I took the defaults and clicked next the rest of the way through it. I was not that familiar with Photon OS, just using it as a pre-built appliance. So I'm gonna post a link to the documentation site. It was very useful to me.

https://vmware.github.io/photon/assets/files/html/1.0-2.0/index.html

Once the OVA is deployed there is some basic config to do before getting to deep into this. First is to set a root password. below is a clip from the documentation on the process.

Once we have the password set next we will need to setup the networking. Here is another clip from the documentation on the network setup. The config below is for setting a static IP. If you are using DHCP skip this step. That part should already be working.

Now that we have our root password set and assigned the server a IP we are ready to configure the server. This was the part where I had a lot of trouble. Lets go back to the github site.

https://github.com/vmw-loginsight/webhook-shims

Scroll down through the README file to the installation section. For this we will use the directions in the Photon 2.0. Now these directions as they are listed did not work for me. One thing to mention here, I am not much of a linux guy. After trying for a hour or so to figure out why the directions were not working I enlisted the help of my best friend Marc. He has been a linux guy forever is seems like. I want to thank him again for dropping what he was doing and helping me. I would have never figured out what was going on. Here is a link to his twitter profile. https://twitter.com/linux_marc?s=20

For the Photon 2 installation, below are the steps that ended up working for us. Here are the commands you will need to get this working. I will post below about the issues we had to correct.

tdnf install curl

tdnf install wget python2 python-xml -y

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

pip install virtualenv

tdnf install git -y

virtualenv loninsightwebhookdemo

cd loginsightwebhookdemo

source bin/activate

git clone https://github.com/vmw-loginsight/webhook-shims.git

cd webhook-shims/

pip install -r requirements.txt

iptables -A INPUT -p tcp --dport 5001 -j ACCEPT

Next, we will have to configure the shim for the product we are using. Under loginsightwebhookdemo/ find the msteams.py file. For this part I enabled SSH and logged to the machine with WinSCP. I edited the file from here. When you open the msteams.py file scroll down about 20 lines or so and find the section shown below.

Here we want to paste the URL that the incoming webhook connector have us in the beginning. Then save the file. Once the file is saved go back to the command line of the server and type this command.

python runserver.py 5001

At this point the server should be configured and ready. To test, go to http://ipaddress:5001/ if the server is working you will see a page like this;

All that left is configure a rest notification outbound setting in vROPS. Here is how mine looked. I am using version 8.1 of vROPS. To find the outbound settings. click Administration at the top. expand Management on the left side and click Outbound Settings. Click the ADD button in the center section. Here is what the screen will look like;

Select Rest Notification Plugin. Give the Instance a name, paste the shim server url in the URL space. besure to add /endpoint/msteams to the url so the teams shim will work. In the content type be sure to select application/json ,here is what my finished product looked like.

So from here the config is done for the most part. The only thing left to do is configure alerts in vROPS to use the outbound instance. For this part, Click Alerts at the top, expand configuration and select Notifications. Once here click ADD under Notifications. the Add Rule Screen will appear as below.

The next screenshot is how I set up a notification for a VM alert. These options can be configured as you wish.

Save the rule. That should be all that is necessary to make this work. Here is a screenshot of the alerts as they come into teams. I really like that the alert is color coded. I send the alerts as the are open, updated, and closed. This can be a little much for some. I personally like to see when the alert goes away.

Well, there it is. We have our vROPS alerts coming into teams.

Now, before I post all the reference links I wanted talk a little bit about the problems I had getting this working. I ran in to a couple different errors. The one that drove me crazy was this;

This was where I got Marc involved, I would have never figured this out. Turns out when you follow the commands in the github repo for installing python it installed two versions of Python. Version 2.6 and Version 3.7. Not to go to in-depth, we uninstalled version 3.7, then ran the command tdnf install wget python2 python-xml -y

This seems to get rid of the ImportError: No Module named xml.etree.ElementTree from there Marc noticed that curl was not installed on the machine. So we installed that. After correcting these two items things started working for us. The directions posted above should work fine on the Photon OS 2.

Now for the reference links.

https://www.prajwaldesai.com/add-incoming-webhook-to-a-teams-channel/

https://communities.vmware.com/thread/593868

https://stackoverflow.com/questions/33633954/python-error-importerror-no-module-named-xml-etree

https://vmware.github.io/photon/assets/files/html/1.0-2.0/tdnf.html

https://doogleit.github.io/2018/03/posting-alerts-to-teams/#

https://github.com/vmw-loginsight/webhook-shims

https://docs.vmware.com/en/vRealize-Operations-Manager/6.4/com.vmware.vcom.core.doc/GUID-2A26A734-CD91-43E0-BF42-B079D5B0F5D4.html

https://blogs.vmware.com/management/2017/02/self-healing-datacenter.html

https://blogs.vmware.com/management/2017/02/self-healing-data-center-2.html

https://blogs.vmware.com/management/2017/02/self-healing-data-center-part-3.html

https://blogs.vmware.com/management/2017/02/self-healing-data-center-part-4.html

https://blogs.vmware.com/management/2017/02/self-healing-data-center-part-5.html

https://stackoverflow.com/questions/33633954/python-error-importerror-no-module-named-xml-etree

https://vmware.github.io/photon/?src=so_5703fb3d92c20&cid=70134000001M5td

https://vmware.github.io/photon/assets/files/html/1.0-2.0/photon-os-troubleshooting-guide.html?q=

https://github.com/vmware/photon/wiki/Downloading-Photon-OS

https://blogs.vmware.com/management/2017/01/vrealize-webhooks-infinite-integrations.html

https://vrealizeandbeyond.com/2020/03/vrops-8-slack-notification-integration-with-webhook-shims/

Thanks for reading!