Skip to content

Commit

Permalink
Update to dogshell monitor _post method - tag ingestion (#356)
Browse files Browse the repository at this point in the history
* Added tag ingestion via args.tags to _post method, tags to _post method res object, and --tags to post_parser.add_argument

* Linting - removed trailing whitespace

Failed Flake8 check.

* Reformatted for Lint removal

* Tags set generation - check for truth

Checking for empty string in tag set generation -  `....if t.strip()` instead of `.....if t`
  • Loading branch information
bradleyjay authored and zippolyte committed Jun 4, 2019
1 parent 228a124 commit b9e356e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion datadog/dogshell/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def setup_parser(cls, subparsers):
post_parser.add_argument('--name', help="name of the alert", default=None)
post_parser.add_argument('--message', help="message to include with notifications"
" for this monitor", default=None)
post_parser.add_argument('--tags', help="comma-separated list of tags", default=None)
post_parser.add_argument('--options', help="json options for the monitor", default=None)
post_parser.set_defaults(func=cls._post)

Expand Down Expand Up @@ -113,8 +114,14 @@ def _post(cls, args):
options = json.loads(args.options)
except:
raise Exception('bad json parameter')

if args.tags:
tags = sorted(set([t.strip() for t in args.tags.split(',') if t.strip()]))
else:
tags = None

res = api.Monitor.create(type=args.type, query=args.query, name=args.name,
message=args.message, options=options)
message=args.message, tags=tags, options=options)
report_warnings(res)
report_errors(res)
if format == 'pretty':
Expand Down

0 comments on commit b9e356e

Please sign in to comment.