diff --git a/doc/source/contributor/notifier-webhook-plugin.rst b/doc/source/contributor/notifier-webhook-plugin.rst index 6776942dc..cfe107e3e 100644 --- a/doc/source/contributor/notifier-webhook-plugin.rst +++ b/doc/source/contributor/notifier-webhook-plugin.rst @@ -65,25 +65,15 @@ Data is sent by the webhook notifier in the following format. "update_timestamp": "2018-01-22 10:00:34.327142+00:00", "vitrage_category": "RESOURCE", "vitrage_operational_state": "OK", - "state": "active", "vitrage_type": "nova.instance", - "vitrage_sample_timestamp": "2018-01-22 10:00:34.327142+00:00", - "vitrage_aggregated_state": "ACTIVE", - "host_id": "iafek-devstack-pre-queens", "project_id": "8f007e5ba0944e84baa6f2a4f2b5d03a", "id": "9b7d93b9-94ec-41e1-9cec-f28d4f8d702c" }, - "severity": "warning", "update_timestamp": "2018-01-22T10:00:34Z", - "resource_id": "437f1f4c-ccce-40a4-ac62-1c2f1fd9f6ac", "vitrage_category": "ALARM", "state": "Active", "vitrage_type": "vitrage", - "vitrage_sample_timestamp": "2018-01-22 10:00:34.366364+00:00", "vitrage_operational_severity": "WARNING", - "vitrage_aggregated_severity": "WARNING", - "vitrage_resource_id": "437f1f4c-ccce-40a4-ac62-1c2f1fd9f6ac", - "vitrage_resource_type": "nova.instance", "name": "Instance memory performance degraded" } } diff --git a/vitrage/notifier/plugins/webhook/webhook.py b/vitrage/notifier/plugins/webhook/webhook.py index 7df4f8788..3157afa4a 100644 --- a/vitrage/notifier/plugins/webhook/webhook.py +++ b/vitrage/notifier/plugins/webhook/webhook.py @@ -29,11 +29,34 @@ from vitrage import storage LOG = logging.getLogger(__name__) URL = 'url' IS_ADMIN_WEBHOOK = 'is_admin_webhook' -FIELDS_TO_REMOVE = (VProps.VITRAGE_IS_PLACEHOLDER, - VProps.VITRAGE_IS_DELETED, - VProps.IS_REAL_VITRAGE_ID) NOTIFICATION_TYPE = 'notification_type' +NOTIFICATION = 'notification' PAYLOAD = 'payload' +ALARM_FILTER = (NOTIFICATION, + PAYLOAD, + VProps.VITRAGE_ID, + VProps.ID, + VProps.RESOURCE, + VProps.NAME, + VProps.UPDATE_TIMESTAMP, + VProps.VITRAGE_OPERATIONAL_STATE, + VProps.VITRAGE_TYPE, + VProps.PROJECT_ID, + VProps.UPDATE_TIMESTAMP, + VProps.VITRAGE_CATEGORY, + VProps.STATE, + VProps.VITRAGE_OPERATIONAL_SEVERITY) +RESOURCE_FILTER = (VProps.VITRAGE_ID, + VProps.ID, + VProps.RESOURCE, + VProps.NAME, + VProps.VITRAGE_CATEGORY, + VProps.UPDATE_TIMESTAMP, + VProps.VITRAGE_OPERATIONAL_STATE, + VProps.VITRAGE_TYPE, + VProps.PROJECT_ID, + VProps.UPDATE_TIMESTAMP, + VProps.VITRAGE_OPERATIONAL_SEVERITY) class Webhook(NotifierBase): @@ -129,10 +152,11 @@ class Webhook(NotifierBase): return True def _filter_fields(self, data): - data = {k: v for k, v in data.items() if k not in FIELDS_TO_REMOVE} + data = {k: v for k, v in data.items() if k in ALARM_FILTER} if data.get(VProps.RESOURCE): data[VProps.RESOURCE] = \ - self._filter_fields(data[VProps.RESOURCE]) + {k: v for k, v in data[VProps.RESOURCE].items() if k in + RESOURCE_FILTER} return data def _check_correct_tenant(self, webhook, data):