From b68c2ffec9ce08f9b1736e090335736f93706dde Mon Sep 17 00:00:00 2001 From: Vincent Bisserie Date: Thu, 3 Jun 2021 15:18:16 +0200 Subject: [PATCH] Encode json output before writing test data Signed-off-by: Vincent Bisserie --- elastalert/test_rule.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elastalert/test_rule.py b/elastalert/test_rule.py index 0797985d..041fa04e 100644 --- a/elastalert/test_rule.py +++ b/elastalert/test_rule.py @@ -434,7 +434,7 @@ def run_rule_test(self): with open(args.save, 'wb') as data_file: # Add _id to _source for dump [doc['_source'].update({'_id': doc['_id']}) for doc in hits] - data_file.write(json.dumps([doc['_source'] for doc in hits], indent=4)) + data_file.write(str.encode(json.dumps([doc['_source'] for doc in hits], indent=4))) if args.use_downloaded: if hits: args.json = args.save