jertel / elastalert2

ElastAlert 2 is a continuation of the original yelp/elastalert project. Pull requests are appreciated!

Home Page:https://elastalert2.readthedocs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while setting up Elastalert2 "AttributeError: module 'datetime' has no attribute 'UTC' "

parvvam opened this issue · comments

While setting up elastalert2 via a python package, after configuring the rule, and testing it I am getting error : "AttributeError: module 'datetime' has no attribute 'UTC' ".

root@server01:~# elastalert-test-rule test_rule.yml
Traceback (most recent call last):
File "/usr/local/bin/elastalert-test-rule", line 8, in
sys.exit(main())
File "/usr/local/lib/python3.10/dist-packages/elastalert/test_rule.py", line 510, in main
test_instance = MockElastAlerter(args)
File "/usr/local/lib/python3.10/dist-packages/elastalert/test_rule.py", line 174, in init
self.ts_now = ts_now()
File "/usr/local/lib/python3.10/dist-packages/elastalert/util.py", line 212, in ts_now
now = datetime.datetime.now(tz=datetime.UTC)
AttributeError: module 'datetime' has no attribute 'UTC'

please find the contents of test_rule.yml

index: pglogs-*
type: frequency
num_events: 15
timeframe:
hours: 4
filter:

  • term:
    event_action: "db=postgres"
    alert:
  • "id@gmail.com"
    email:
  • "email"
    smtp_host: smtp.gmail.com
    smtp_port: 587
    smtp_auth_file: smtp_auth.yaml

mstsc_TR3nMfzWc8

Read #11 before posting.

See #1400.