diff --git a/Alerting/Sample Watches/run_test.py b/Alerting/Sample Watches/run_test.py index 234177501..72b9a57ca 100755 --- a/Alerting/Sample Watches/run_test.py +++ b/Alerting/Sample Watches/run_test.py @@ -33,6 +33,7 @@ def load_file(serialized_file): parser.add_argument('--protocol', help='protocol') parser.add_argument('--test_file', help='test file') parser.add_argument('--keep-index', help='Keep the index where test documents have been loaded to after the test', action='store_true') + parser.add_argument('--modify-watch-by-eval', help='Python code to modify the watch before loading it into Elastic') parser.add_argument( '--no-execute-watch', help='Do not force watch execution. This can be useful when you use this script to deploy the watch.', @@ -79,6 +80,10 @@ def load_file(serialized_file): # Load Watch and Execute watch = load_file(test['watch_file']) + + if args.modify_watch_by_eval: + eval(compile(args.modify_watch_by_eval, '', 'exec')) + watcher = XPackClient(es).watcher watcher.put_watch(id=test["watch_name"], body=watch)