From 8265b2d489a89d524d1cf97c50f6bfaacef86f8f Mon Sep 17 00:00:00 2001 From: Rudy Date: Tue, 6 May 2014 12:24:39 -0400 Subject: [PATCH 1/2] Dogshell| Enable the type and aggregation_key argument to post event --- src/dogapi/http/events.py | 8 +++++++- src/dogshell/event.py | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/dogapi/http/events.py b/src/dogapi/http/events.py index 5a645fa..9dd0d4d 100644 --- a/src/dogapi/http/events.py +++ b/src/dogapi/http/events.py @@ -80,7 +80,7 @@ def get_event(self, id): response_formatter=lambda x: x['event'], ) - def _event(self, title, text, date_happened=None, handle=None, priority=None, related_event_id=None, tags=None, host=None, device_name=None, aggregation_key=None, **kwargs): + def _event(self, title, text, date_happened=None, handle=None, priority=None, related_event_id=None, tags=None, host=None, device_name=None, aggregation_key=None, event_type= None,**kwargs): """ Post an event. @@ -114,6 +114,9 @@ def _event(self, title, text, date_happened=None, handle=None, priority=None, re :param aggregation_key: key to aggregate this event on :type aggregation_key: string + :param event_type: type of event to post the event with + :type event_type: string + :return: new event id :rtype: integer """ @@ -146,6 +149,9 @@ def _event(self, title, text, date_happened=None, handle=None, priority=None, re if aggregation_key is not None: body['aggregation_key'] = aggregation_key + if event_type is not None: + body['source_type_name'] = event_type + body.update(kwargs) return self.http_request('POST', '/events', body, diff --git a/src/dogshell/event.py b/src/dogshell/event.py index 4aaf721..7b23e4b 100644 --- a/src/dogshell/event.py +++ b/src/dogshell/event.py @@ -65,6 +65,7 @@ def setup_parser(self, subparsers): post_parser.add_argument('--tags', help='comma separated list of tags') post_parser.add_argument('--host', help='related host') post_parser.add_argument('--device', help='related device (e.g. eth0, /dev/sda1)') + post_parser.add_argument('--aggregation_key', help='key to aggregate the event with') post_parser.add_argument('--type', help='type of event, e.g. nagios, jenkins, etc.') post_parser.add_argument('message', help='event message body. if unset, reads from stdin.', nargs="?") post_parser.set_defaults(func=self._post) @@ -99,7 +100,9 @@ def _post(self, args): args.related_event_id, tags, args.host, - args.device) + args.device, + args.aggregation_key, + args.type) report_warnings(res) report_errors(res) if format == 'pretty': From b8993561e93a12dca98be7ebfee3b29de23eee20 Mon Sep 17 00:00:00 2001 From: Rudy Date: Wed, 7 May 2014 11:12:06 -0400 Subject: [PATCH 2/2] Dogshell| Rename event_type agrument into source_type_name --- src/dogapi/http/events.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dogapi/http/events.py b/src/dogapi/http/events.py index 9dd0d4d..f708466 100644 --- a/src/dogapi/http/events.py +++ b/src/dogapi/http/events.py @@ -80,7 +80,7 @@ def get_event(self, id): response_formatter=lambda x: x['event'], ) - def _event(self, title, text, date_happened=None, handle=None, priority=None, related_event_id=None, tags=None, host=None, device_name=None, aggregation_key=None, event_type= None,**kwargs): + def _event(self, title, text, date_happened=None, handle=None, priority=None, related_event_id=None, tags=None, host=None, device_name=None, aggregation_key=None, source_type_name=None,**kwargs): """ Post an event. @@ -114,8 +114,8 @@ def _event(self, title, text, date_happened=None, handle=None, priority=None, re :param aggregation_key: key to aggregate this event on :type aggregation_key: string - :param event_type: type of event to post the event with - :type event_type: string + :param source_type_name: type of event to post the event with + :type source_type_name: string :return: new event id :rtype: integer @@ -149,8 +149,8 @@ def _event(self, title, text, date_happened=None, handle=None, priority=None, re if aggregation_key is not None: body['aggregation_key'] = aggregation_key - if event_type is not None: - body['source_type_name'] = event_type + if source_type_name is not None: + body['source_type_name'] = source_type_name body.update(kwargs)