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: 'module' object has no attribute 'FullLoader' #2298

Open
guoyingying12 opened this issue Jun 17, 2019 · 8 comments
Open

AttributeError: 'module' object has no attribute 'FullLoader' #2298

guoyingying12 opened this issue Jun 17, 2019 · 8 comments

Comments

@guoyingying12
Copy link

Hi,
When I started elastalert,I reported the following error.Can you help me?

python -m elastalert.elastalert --config ./config.yaml --rule ./example_rules/prod_dsg.yaml

Traceback (most recent call last):
File "/usr/lib64/python2.7/runpy.py", line 162, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/usr/lib64/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/data/elastalert/elastalert/elastalert.py", line 22, in
from config import get_rule_hashes
File "elastalert/config.py", line 31, in
rule_schema = jsonschema.Draft4Validator(yaml.load(open(os.path.join(os.path.dirname(file), 'schema.yaml')), Loader=yaml.FullLoader))
AttributeError: 'module' object has no attribute 'FullLoader'

@JackyShin
Copy link

FullLoader can't be used in python2.7, find config.py and delete Loader=yaml.FullLoader.

@guoyingying12
Copy link
Author

FullLoader can't be used in python2.7, find config.py and delete Loader=yaml.FullLoader.

Hi~
Thanks,I delete 'Loader=yaml.FullLoader',but when I started elastalert,I reported the following new error.
elastalert 0.1.39
elasticsearch 6.7.2

python -m elastalert.elastalert --config /data/elastalert/config.yaml --verbose --rule /data/elastalert/example_rules/prod_dsg.yaml

###########################################################################
INFO:elastalert:Starting up
WARNING:elasticsearch:GET http://172.16.19.239:9200/elastalert_status/_search?size=1000 [status:400 request:0.005s]
ERROR:root:Error finding recent pending alerts: RequestError(400, u'search_phase_execution_exception', u'No mapping found for [alert_time] in order to sort on') {'sort': {'alert_time': {'order': 'asc'}}, 'query': {'bool': {'filter': {'range': {'alert_time': {'to': '2019-06-17T07:58:03.461081Z', 'from': '2019-06-15T07:58:03.461053Z'}}}, 'must': {'query_string': {'query': '!exists:aggregate_id AND alert_sent:false'}}}}}
Traceback (most recent call last):
File "/data/elastalert/elastalert/elastalert.py", line 1519, in find_recent_pending_alerts
res = self.writeback_es.search(index=self.writeback_index, body=query, size=1000)
File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/lib/python2.7/site-packages/elasticsearch/client/init.py", line 819, in search
"GET", _make_path(index, "_search"), params=params, body=body
File "/usr/lib/python2.7/site-packages/elasticsearch/transport.py", line 353, in perform_request
timeout=timeout,
File "/usr/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py", line 155, in perform_request
self._raise_error(response.status_code, raw_data)
File "/usr/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 178, in _raise_error
status_code, error_message, additional_info
RequestError: RequestError(400, u'search_phase_execution_exception', u'No mapping found for [alert_time] in order to sort on')
INFO:elastalert:Queried rule prod_dsg from 2019-06-17 15:43 CST to 2019-06-17 15:58 CST: 0 / 0 hits
INFO:elastalert:Ran prod_dsg from 2019-06-17 15:43 CST to 2019-06-17 15:58 CST: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 59.945863 seconds

@nicholasgibson2
Copy link

nicholasgibson2 commented Jun 28, 2019

FullLoader can't be used in python2.7, find config.py and delete Loader=yaml.FullLoader.

In that case what version of Python are you supposed to run? ElastAlert documentation says to use 2.7.
https://elastalert.readthedocs.io/en/latest/running_elastalert.html#requirements

@JackyShin
Copy link

FullLoader can't be used in python2.7, find config.py and delete Loader=yaml.FullLoader.

Hi~
Thanks,I delete 'Loader=yaml.FullLoader',but when I started elastalert,I reported the following new error.
elastalert 0.1.39
elasticsearch 6.7.2

python -m elastalert.elastalert --config /data/elastalert/config.yaml --verbose --rule /data/elastalert/example_rules/prod_dsg.yaml

###########################################################################
INFO:elastalert:Starting up
WARNING:elasticsearch:GET http://172.16.19.239:9200/elastalert_status/_search?size=1000 [status:400 request:0.005s]
ERROR:root:Error finding recent pending alerts: RequestError(400, u'search_phase_execution_exception', u'No mapping found for [alert_time] in order to sort on') {'sort': {'alert_time': {'order': 'asc'}}, 'query': {'bool': {'filter': {'range': {'alert_time': {'to': '2019-06-17T07:58:03.461081Z', 'from': '2019-06-15T07:58:03.461053Z'}}}, 'must': {'query_string': {'query': '!exists:aggregate_id AND alert_sent:false'}}}}}
Traceback (most recent call last):
File "/data/elastalert/elastalert/elastalert.py", line 1519, in find_recent_pending_alerts
res = self.writeback_es.search(index=self.writeback_index, body=query, size=1000)
File "/usr/lib/python2.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/lib/python2.7/site-packages/elasticsearch/client/init.py", line 819, in search
"GET", _make_path(index, "_search"), params=params, body=body
File "/usr/lib/python2.7/site-packages/elasticsearch/transport.py", line 353, in perform_request
timeout=timeout,
File "/usr/lib/python2.7/site-packages/elasticsearch/connection/http_requests.py", line 155, in perform_request
self._raise_error(response.status_code, raw_data)
File "/usr/lib/python2.7/site-packages/elasticsearch/connection/base.py", line 178, in _raise_error
status_code, error_message, additional_info
RequestError: RequestError(400, u'search_phase_execution_exception', u'No mapping found for [alert_time] in order to sort on')
INFO:elastalert:Queried rule prod_dsg from 2019-06-17 15:43 CST to 2019-06-17 15:58 CST: 0 / 0 hits
INFO:elastalert:Ran prod_dsg from 2019-06-17 15:43 CST to 2019-06-17 15:58 CST: 0 query hits (0 already seen), 0 matches, 0 alerts sent
INFO:elastalert:Sleeping for 59.945863 seconds

query syntax or query attributes seems to have some problem, check query itself and the index. Is it a timeseries index including @timestamp inside or someelse

@JackyShin
Copy link

FullLoader can't be used in python2.7, find config.py and delete Loader=yaml.FullLoader.

In that case what version of Python are you supposed to run? ElastAlert documentation says to use 2.7.
https://elastalert.readthedocs.io/en/latest/running_elastalert.html#requirements

not sure the problem is led into by python version or someelse such as environment, just found that FullLoader was used since a centain version of elastalert,so this method should work without effecting any function at least so far

@guoyingying12
Copy link
Author

FullLoader can't be used in python2.7, find config.py and delete Loader=yaml.FullLoader.

In that case what version of Python are you supposed to run? ElastAlert documentation says to use 2.7.
https://elastalert.readthedocs.io/en/latest/running_elastalert.html#requirements

not sure the problem is led into by python version or someelse such as environment, just found that FullLoader was used since a centain version of elastalert,so this method should work without effecting any function at least so far

Now, elastalert was installed successfully.
ENV:elasticsearch,kibana ->5.6.16
logstash,filebeat ->6.7.2(5.6.16 is ok also)

Reinstall it,python must uninstall Depend on the package

@Evasion
Copy link

Evasion commented Aug 30, 2019

you need to install PyYAML using pip
pip install PyYAML==5.1 should fix the problem

@jerrac
Copy link

jerrac commented Nov 5, 2019

I ran into the FullLoader message while running elastalert-create-index.
When I tried to install PyYAML, I got this message:

Requirement already satisfied: PyYAML in /usr/local/lib/python2.7/dist-packages (3.13)

I'm guessing that is why @Evasion added the version to the install command. pip install PyYAML --upgrade fixed it for me.

So, thanks @Evasion !

Would a documentation change or modification of what happens when you run python setup.py install help people not run into this error?

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

5 participants