vmw-loginsight / webhook-shims

Shims for Log Insight 3.3+ and vRealize Operations Manager 6.0+
Apache License 2.0
38 stars 31 forks source link

parsevROps #48

Closed Sureshhm closed 6 years ago

Sureshhm commented 7 years ago

I can see parsed details as below mentioned, but when we try jira post we dont see these details in description field. Description field is set as "description": a['moreinfo'], any help on this would be appreciated.

Parsed={'status': u'ACTIVE', 'criticality': u'ALERT_CRITICALITY_LEVEL_CRITICAL', 'editurl': '', 'Messages': '', 'subType': u'ALERT_SUBTYPE_AVAILABILITY_PROBLEM', 'Health': 4, 'AlertName': u'Private Cloud Virtual Machine Is Down', 'resourceName': u'prodlnx30634', 'moreinfo': u'Private Cloud Virtual Machine Is Down\n\n', 'hookName': 'vRealize Operations Manager', 'color': 'red', 'icon': 'http://blogs.vmware.com/management/files/2016/09/vrops-256.png', 'info': u'', 'Risk': 1, 'url': '', 'fields': [{'content': '4', 'name': 'Health'}, {'content': '1', 'name': 'Risk'}, {'content': '1', 'name': 'Efficiency'}, {'content': u'prodlnx30634', 'name': 'Resouce Name'}, {'content': u'VMWARE', 'name': 'Adapter Kind'}, {'content': u'ALERT_TYPE_VIRTUALIZATION_PROBLEM', 'name': 'Type'}, {'content': u'ALERT_SUBTYPE_AVAILABILITY_PROBLEM', 'name': 'Sub Type'}], 'Efficiency': 1, 'adapterKind': u'VMWARE', 'type': u'ALERT_TYPE_VIRTUALIZATION_PROBLEM'}

Thanks

flands commented 7 years ago

The logic today is that the info part of the incoming payload is used: https://github.com/vmw-loginsight/webhook-shims/blob/b1fd9529dc4fd9ec9feb0d12075d11b71090f011/loginsightwebhookdemo/__init__.py#L189

You could change this logic to send whatever you want including the additional fields. Note this behavior is the same for LI as well as vROps. Arguably, this is not as useful as it could be. Feel free to submit a pull request or I can take a look in a bit.

flands commented 7 years ago

Pull request up: https://github.com/vmw-loginsight/webhook-shims/pull/51

Net result is all data is passed:


2017-11-16 12:44:44,944 INFO Please navigate to the below URL for the available routes
2017-11-16 12:44:44,954 INFO  * Running on http://0.0.0.0:5001/ (Press CTRL+C to quit)
2017-11-16 12:44:52,747 INFO {"startDate":1369757346267,"criticality":"ALERT_CRITICALITY_LEVEL_WARNING","Risk":4.0,"resourceId":"sample-object-uuid","alertId":"sample-alert-uuid","status":"ACTIVE","subType":"ALERT_SUBTYPE_AVAILABILITY_PROBLEM","cancelDate":1369757346267,"resourceKind":"sample-object-type","alertName":"Invalid IP Address for connected Leaf Switch","attributeKeyID":5325,"Efficiency":1.0,"adapterKind":"sample-adapter-type","Health":1.0,"type":"ALERT_TYPE_APPLICATION_PROBLEM","resourceName":"sample-object-name","updateDate":1369757346267,"info":"sample-info"}
2017-11-16 12:44:52,747 INFO Parsed={'status': u'ACTIVE', 'startDate': 1369757346267, 'criticality': u'ALERT_CRITICALITY_LEVEL_WARNING', 'editurl': '', 'resourceId': u'sample-object-uuid', 'Messages': '', 'subType': u'ALERT_SUBTYPE_AVAILABILITY_PROBLEM', 'Health': 1.0, 'AlertName': u'Invalid IP Address for connected Leaf Switch', 'resourceName': u'sample-object-name', 'moreinfo': u"Hello from the webhook shim! This is a test webhook alert.\n\nAlert Name: Invalid IP Address for connected Leaf Switch\nAlert Info: sample-info\nAlert Details: [{'content': '1.0', 'name': 'Health'}, {'content': '4.0', 'name': 'Risk'}, {'content': '1.0', 'name': 'Efficiency'}, {'content': u'sample-object-name', 'name': 'Resouce Name'}, {'content': u'sample-adapter-type', 'name': 'Adapter Kind'}, {'content': u'ALERT_TYPE_APPLICATION_PROBLEM', 'name': 'Type'}, {'content': u'ALERT_SUBTYPE_AVAILABILITY_PROBLEM', 'name': 'Sub Type'}]", 'hookName': 'vRealize Operations Manager', 'color': 'yellow', 'icon': 'http://blogs.vmware.com/management/files/2016/09/vrops-256.png', 'info': u'sample-info', 'Risk': 4.0, 'alertId': u'sample-alert-uuid', 'url': '', 'fields': [{'content': '1.0', 'name': 'Health'}, {'content': '4.0', 'name': 'Risk'}, {'content': '1.0', 'name': 'Efficiency'}, {'content': u'sample-object-name', 'name': 'Resouce Name'}, {'content': u'sample-adapter-type', 'name': 'Adapter Kind'}, {'content': u'ALERT_TYPE_APPLICATION_PROBLEM', 'name': 'Type'}, {'content': u'ALERT_SUBTYPE_AVAILABILITY_PROBLEM', 'name': 'Sub Type'}], 'Efficiency': 1.0, 'adapterKind': u'sample-adapter-type', 'updateDate': 1369757346267, 'type': u'ALERT_TYPE_APPLICATION_PROBLEM'}
2017-11-16 12:44:52,747 INFO Hello from the webhook shim! This is a test webhook alert.

Alert Name: Invalid IP Address for connected Leaf Switch
Alert Info: sample-info
Alert Details: [{'content': '1.0', 'name': 'Health'}, {'content': '4.0', 'name': 'Risk'}, {'content': '1.0', 'name': 'Efficiency'}, {'content': u'sample-object-name', 'name': 'Resouce Name'}, {'content': u'sample-adapter-type', 'name': 'Adapter Kind'}, {'content': u'ALERT_TYPE_APPLICATION_PROBLEM', 'name': 'Type'}, {'content': u'ALERT_SUBTYPE_AVAILABILITY_PROBLEM', 'name': 'Sub Type'}]
2017-11-16 12:44:52,748 INFO 127.0.0.1 - - [16/Nov/2017 12:44:52] "POST /endpoint/test HTTP/1.1" 200 -```
Sureshhm commented 7 years ago

Thanks Flands, I have managed to get it working last week .. it's working fine and I'm receiving Jira alert as expected.

vmw-loginsight commented 6 years ago

Merge was completed so closing this