Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: '_thread._local' object has no attribute 'alerts_sent' #2634

Closed
gcnote opened this issue Jan 8, 2020 · 9 comments
Closed

Comments

@gcnote
Copy link

gcnote commented Jan 8, 2020

run elastalert-test-rule with python 3.6.0 and python 3.6.9 have same problem,
which version of python should use?

ERROR:root:Traceback (most recent call last):
File "/opt/pyenv/versions/elastalert_360/lib/python3.6/site-packages/elastalert-0.2.1-py3.6.egg/elastalert/elastalert.py", line 1451, in alert
return self.send_alert(matches, rule, alert_time=alert_time, retried=retried)
File "/opt/pyenv/versions/elastalert_360/lib/python3.6/site-packages/elastalert-0.2.1-py3.6.egg/elastalert/elastalert.py", line 1550, in send_alert
self.thread_data.alerts_sent += 1
AttributeError: '_thread._local' object has no attribute 'alerts_sent'

Elastalert version : 0.2.1

@gcnote gcnote closed this as completed Jan 8, 2020
@Maixy
Copy link

Maixy commented Jan 16, 2020

Seeing the same issue running elastalert-test-rule with the --alert flag enabled (when alerts are actually sent out) - did you find a fix for this @gcnote ?

@nickbabkin
Copy link

+1, seeing the same issue for elastalert-test-rule
Python 3.5.2

Elastalert 0.2.1

@daichi703n
Copy link

This fix discussed in #2556 works for me.

        self.replace_dots_in_field_names = self.conf.get('replace_dots_in_field_names', False)
        self.thread_data.num_hits = 0
        self.thread_data.num_dupes = 0
        self.thread_data.alerts_sent = 0  #add
        self.scheduler = BackgroundScheduler()

https://github.com/Yelp/elastalert/blob/master/elastalert/elastalert.py#L162-L163

Thanks!! @gcnote

@JoshuaSmeda
Copy link

JoshuaSmeda commented Jun 8, 2020

This is still a issue in the latest release.

Can we get a proper fix instead of manually adding in the variable?

@manikantanr
Copy link

manikantanr commented Oct 16, 2020

Still seeing this with latest elastalert.

elastalert[31818]: ERROR:apscheduler.executors.default:Job "ElastAlerter.handle_rule_execution (trigger: interval[0:01:00], next run at: 2020-10-15 21:43:39 PDT)" raised an exception
elastalert[31818]: Traceback (most recent call last):
elastalert[31818]: File "/opt/elastalert_venv/venv/lib/python3.6/site-packages/apscheduler/executors/base.py", line 125, in run_job
elastalert[31818]: retval = job.func(*job.args, **job.kwargs)
elastalert[31818]: File "/opt/elastalert_venv/venv/lib/python3.6/site-packages/elastalert/elastalert.py", line 1278, in handle_rule_execution
elastalert[31818]: self.thread_data.num_hits, self.thread_data.num_dupes, num_matches,
elastalert[31818]: AttributeError: '_thread._local' object has no attribute 'num_hits'

Whats the reason for this?

@nsano-rururu
Copy link
Contributor

@daichi703n

Is there a problem that this fix hasn't solved yet?
If there is no problem, make a pull request.

@daichi703n
Copy link

@nsano-rururu
I created PR #2991. Please check it.

@nsano-rururu
Copy link
Contributor

@daichi703n

I will try it on the weekend. Thank you.

@nsano-rururu
Copy link
Contributor

@daichi703n

We apologize for the delay in reporting. confirmed. The problem has been resolved. It will be included as a patch in the next release of ElastAlertServer. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants