jertel / elastalert2

ElastAlert 2 is a continuation of the original yelp/elastalert project. Pull requests are appreciated!
https://elastalert2.readthedocs.org
Apache License 2.0
931 stars 287 forks source link

Type error when testing rule from elastalert in elastalert2 #736

Closed DrewHorrigan closed 2 years ago

DrewHorrigan commented 2 years ago

Hello, I am trying to migrate to elastalert2, and had one of my rules (which worked fine in elastalert) produce the following error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/elastalert/loaders.py", line 321, in load_options
    rule['run_every'] = datetime.timedelta(**rule['run_every'])
TypeError: type object argument after ** must be a mapping, not str

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/elastalert-test-rule", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/elastalert/test_rule.py", line 518, in main
    test_instance.run_rule_test()
  File "/usr/local/lib/python3.6/site-packages/elastalert/test_rule.py", line 465, in run_rule_test
    conf['rules_loader'].load_options(rule_yaml, conf, self.args.file)
  File "/usr/local/lib/python3.6/site-packages/elastalert/loaders.py", line 335, in load_options
    raise EAException('Invalid time format used: %s' % e)
elastalert.util.EAException: Invalid time format used: type object argument after ** must be a mapping, not str

Investigating the problem, I found that the old rule was had this section:

run_every:
  hours:24

I changed this to hours: 24 (added a space), and the modified rule worked fine in both elastalerts. However, I haven't found anything about this in the release notes, so this may be a breaking change someone missed.

nsano-rururu commented 2 years ago

I got the same error with elastalert 0.2.4. It's a lie report. I felt bad faith. Close this issue.

nsano-rururu commented 2 years ago

I thought I couldn't forgive it.