Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #87 from DataDog/dogshell-args
Browse files Browse the repository at this point in the history
Dogshell| Enable the type and aggregation_key argument to post event
  • Loading branch information
bunelr committed May 7, 2014
2 parents 48e8a06 + b899356 commit 52e1fdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/dogapi/http/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, source_type_name=None,**kwargs):
"""
Post an event.
Expand Down Expand Up @@ -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 source_type_name: type of event to post the event with
:type source_type_name: string
:return: new event id
:rtype: integer
"""
Expand Down Expand Up @@ -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 source_type_name is not None:
body['source_type_name'] = source_type_name

body.update(kwargs)

return self.http_request('POST', '/events', body,
Expand Down
5 changes: 4 additions & 1 deletion src/dogshell/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 52e1fdb

Please sign in to comment.