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

Dogshell| Enable the type and aggregation_key argument to post event #87

Merged
merged 2 commits into from
May 7, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, event_type= 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 event_type: type of event to post the event with
:type event_type: 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 event_type is not None:
body['source_type_name'] = event_type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source_type_name and event_type are two different fields, why not just name the parameter source_type_name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks


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