Update: yes it still works with 6.7-8.0, no need to change or remove anything the upgrade just works, for 8.1+ users check out the new blog post here
With this next post I will share my vRops “Custom Rest Outbound Plugin“, what this plugin allows you to do is customize the structure of the XML / JSON sent by vRops to the destination REST listener. (check out this post for a simple Powershell listener you can use to debug / test the structure)
I will start off by saying… use this at your own risk! removal / cleanup of the plugin requires access to the Cassandra DB so it might not be everyone’s cup of tea! + each time vRops upgrades you risk breaking vRops because the plugin prevents “analytics” from starting due to changes in lib’s &/or java versions…. I maintain this for myself and I am happy to do it for the community but I defiantly do not support it!
I am not going to go over the top and write a full on detailed blog post… you should be able to “read between the lines” and work it out…. otherwise this really isn’t for you to play with!
Dowonload for vRops 6.6 – 6.6.1: CustomRestPlugin-vMan-v1.1-vRops_66
Installation of the plugin
1). You will need to stop vRops from the Admin console, take a snapshot, SSH to the vRops server or servers (I run this in a PROD clustered vRops configuration without issues) and follow the install instructions below.
2). The plugin jar will need to be copied to /usr/lib/vmware-vcops/user/plugins/outbound
3). Update /usr/lib/vmware-vcops/user/conf/messages/notificationPlugin.properties with the values below (note if you use vRops in a language other than English you will need to update your respective language file notificationPlugin_**.properties)
CustomRestPlugin.7.longDesc=Content Type CustomRestPlugin.8.shortDesc=Request CustomRestPlugin.7.shortDesc=Content Type CustomRestPlugin.2.shortDesc=User Name CustomRestPlugin.3.shortDesc=Password CustomRestPlugin.9.longDesc=Debug output of XML file to location: /storage/log/vcops/log/XXX-CustomRestOutputXXXX.xml CustomRestPlugin.3.longDesc=Password CustomRestPlugin.1.shortDesc=Url CustomRestPlugin.4.longDesc=SHA-1 thumbprint of the server's Public SSL Certificate CustomRestPlugin.6.longDesc=Method CustomRestPlugin.6.shortDesc=Method CustomRestPlugin.2.longDesc=User Name CustomRestPlugin.8.longDesc=Request CustomRestPlugin.10.shortDesc=Custom Rest Plugin CustomRestPlugin.4.shortDesc=Certificate thumbprint CustomRestPlugin.5.shortDesc=Connection Count CustomRestPlugin.10.longDesc=Custom Rest Plugin CustomRestPlugin.9.shortDesc=Debug XML output to file CustomRestPlugin.5.longDesc=Maximum number of simultaneous connections to the web service CustomRestPlugin.1.longDesc=Url
4). Start vRops from the admin console, wait for it to start up and then login to the GUI, navigate to Administration –> Management –> Outbound Settings
Create a new outbound plugin with the required details
REQUEST EXAMPLE:
<Incident> <DateTime>#startdate#</DateTime> <CallBackAddress>https://vrops.vman.ch/suite-api/api/alerts/#alertid#</CallBackAddress> <Owner>vMAN</Owner> <System>vMAN</System> <TransactionType>Insert</TransactionType> <vROPSIncidentID>#alertid#</vROPSIncidentID> <Category>Application</Category> <Impact>#alertimpact#</Impact> <IncidentDescription>#alertstate# - #alertresourcekind# - #alertresourcename# - #alertname#</IncidentDescription> <IncidentStatus>Open-Assigned</IncidentStatus> <Urgency>#alertcriticality#</Urgency> <AssignmentGroup>vMAN_Automation</AssignmentGroup> <Rating>4</Rating> <Priority>4</Priority> <URL>#alerturl#</URL> </Incident>
I use the <CallBackAddress> for the ticketing system to insert the Incident number back into vRops as a “note”
EXAMPLE REQUEST OUTPUT below…
<Incident> <DateTime>2018-02-17T11:52:25Z</DateTime> <CallBackAddress>https://vrops.vman.ch/suite-api/api/alerts/39f016a9-1862-4c84-9514-6d50f8f09b0d</CallBackAddress> <Owner>vMAN</Owner> <System>vMAN</System> <TransactionType>Insert</TransactionType> <vROPSIncidentID>39f016a9-1862-4c84-9514-6d50f8f09b0d</vROPSIncidentID> <Category>Application</Category> <Impact>health</Impact> <IncidentDescription>add - VirtualMachine - vcsa-peer - Object is down</IncidentDescription> <IncidentStatus>Open-Assigned</IncidentStatus> <Urgency><Urgency>critical</Urgency></Urgency> <AssignmentGroup>vMAN_Automation</AssignmentGroup> <Rating>4</Rating> <Priority>4</Priority> <URL>https://192.168.88.175/ui/index.action#/object/46d32678-11d4-4540-83d6-07af5c754b7c/alertsAndSymptoms/alerts/39f016a9-1862-4c84-9514-6d50f8f09b0d</URL> </Incident>
(note that if you enable debug you will get a file generated here on the vRops server: /storage/log/vcops/log/XXX-CustomRestOutputXXXX.xml)
Here are a list of options that can be used in the REQUEST
#alertstate# #alertadapterkind# #alertdefinitionid# #alertname# #alertdescription# #alertcriticality# #alertefficiency# #alerthealth# #alertimpact# #alertvropservername# #alertvropserver# #alertresourcekind# #alertresourcename# #alertresourceuuid# #alertrisk# #alertstatus# #alerttype# #alertsubtype# #alertid# #alerturl# #startdate# #updatedate# #canceldate#
To use it just create a new rule in Notification Settings and select the clustom outbound plugin for method
To remove the plugin and clean up the vRops Cassandra database
If you have deployed it to the system and want to remove it / clean up the GUI or update the describe.xml you can do so by following the instructions below.
Worth making a snapshot vRops now…
1).Remove what was added to /usr/lib/vmware-vcops/user/plugins/outbound and the /usr/lib/vmware-vcops/user/conf/messages/notificationPlugin.properties
2). Connect to the vRops via SSH, then run the cqlshrc command to connect to the Cassandra DB
cd /usr/lib/vmware-vcops/cassandra/apache-cassandra-2.1.8/bin ./cqlsh --ssl --cqlshrc $VCOPS_BASE/user/conf/cassandra/cqlshrc
3). Run a select looking for the plugin…
SELECT * FROM globalpersistence.notificationplugin WHERE namespace='notificationplugin' AND classtype='notificationplugin' AND key='AlertPluginMetadata.CustomRestPlugin' ALLOW FILTERING;
4). Now delete the record…
DELETE FROM globalpersistence.notificationplugin WHERE namespace='notificationplugin' AND classtype='notificationplugin' AND key='AlertPluginMetadata.CustomRestPlugin';
5). Restart the vmware-vcops service, no need to reboot…
service vmware-vcops restart
vMan
Hey vMan,
I’m trying to use your plugin to post requests to jira and am not able to bypass the setup step. The outbound test fails with following error: ”
Test was not successful: Failed to post or put to the server.”. I have the debugging on, but all I see in the log is the request body.
Could you please help me with troubleshooting?
I have a local jira installed, and am trying to run this post request:
post url – https://10.26.217.107:8443/rest/api/2/issue/
request body – {“fields”:{“project”:{“key”:”MTP”},”summary”:”jira api test -zara”,”description”:”test”,”issuetype”:{“name”:”Bug”}}}
Note that it uses basic auth and I have a self signed certificate installed.
Thanks,
Zara
PS In case of specifying invalid captcha, all of the inputs are lost ?
Hello Zara,
Sorry but the POST / structure in my example was built for vRops not JIRA and I am not familiar with its API.
I suggest you use Chrome Advanced Rest client to get it working which will help you get it working visually then adapt my script to work with JIRA.
Cheers
vMan
There’s a fling that adds a lot of data to alert and allows full customization of the final payload. The best part there is that it doesn’t touch/change anything in vROps (nor its DBs), it works as a third party and never touches any internal data in vROps. So it’s safer.
https://labs.vmware.com/flings/vrealize-operations-rest-notifications-helper
Hi Vman,
I would like to include Content-Type: application/octet-stream with -d option in the form , is there a way to add this ?
is there a way to see the actual post request which is being made
You can add the type to https://github.com/vmanch/vManvRopsCustomREST/blob/vRops_6.3-6.5/com.vMan.vrops6.CustomREST/describe.xml and reimport the plugin… but I have not tried it with options IE: -d, you might have to update the code to support it…. see within… yes see the output when using debug in the config, output goes to /storage/log/vcops/log/XXX-CustomRestOutputXXXX…..
Hi Vman thanks for your reply
I have tried editing the decribe.xml and tried exporting the jar ,it finished with warning , ie messages with expoted with errors /src/com/vman/alertplugins /customrest/customeRestSender.java
could you please help me on this, i just wanted to add
application/octet-stream
You will need to completely remove the jar and cleanup the DB by removing all references of the custom plugin. Check the removal section of the post. Once that’s done you should be able to add it again so the the update for the octet-stream
Does this still work for 7.0 and 7.5?
Yes I use it in multiple production environments without issues. Just make sure to get the latest one from github.
Does this still work on 8.1?
I have not upgraded to 8.1 yet, but once I do I will reply here…. i know it works with 8.0.
So i can confirm it doesn’t work on vRops 8.1, I suspect they have updated the java version and dependant libs… I will be working on a fix in the next few weeks.