Yelp / elastalert

Easy & Flexible Alerting With ElasticSearch
https://elastalert.readthedocs.org
Apache License 2.0
7.99k stars 1.74k forks source link

ImportError: No module named base.exceptions #1003

Open gjobin opened 7 years ago

gjobin commented 7 years ago

Hi, getting this error since I switched from v0.1.8 to master to get the Fix on AWS.

Creating Elastalert index in Elasticsearch... Index elastalert_status already exists. Skipping index creation. Traceback (most recent call last): File "elastalert/elastalert.py", line 20, in from alerts import DebugAlerter File "/opt/elastalert/elastalert/alerts.py", line 26, in from twilio.base.exceptions import TwilioRestException ImportError: No module named base.exceptions

Can you please help me ?

Thanks, Guillaume

Dgadavin commented 7 years ago

+1

Qmando commented 7 years ago

pip install twilio==6.0.0

gjobin commented 7 years ago

The default version I get is twilio 6.3.dev0 after python setup.py install

pip install twilio==6.0.0 crashes with compilation errors. pip install twilio==5.7.0 works but Elastalert give same errors as reported.

Qmando commented 7 years ago

You get this exception when 6.3.dev0 is installed?

Regarding the error for 6.0.0, is it while compiling cryptography library? You probably need libssl-dev and maybe libffi-dev

gjobin commented 7 years ago

You get this exception when 6.3.dev0 is installed? Yes

I will look into suggested packages and report back

gjobin commented 7 years ago

The compilation error is indeed related to cryptography library. I can install libffi-dev without problem, but libssl-dev is giving me this error :

/opt/elastalert # apk add libssl-dev
ERROR: unsatisfiable constraints:
  libssl-dev (missing):
    required by: world[libssl-dev]
Qmando commented 7 years ago

Ah, this one is slightly different on apt and apk. Try openssl-dev instead

tatdatpham commented 7 years ago

i got same error in lasted version ElasticAlert (Centos 6)

gjobin commented 7 years ago

Thank you @Qmando, your suggestions fixed it for me. Here is my resulting docker installcommands :

RUN apk add --update \
    ca-certificates \
    openssl-dev \
    libffi-dev \
    build-base \
  && rm -rf /var/cache/apk/*

# Install Elastalert.
RUN python setup.py install && \
    pip install -e . && \
    pip uninstall twilio --yes && \
    pip install twilio==6.0.0

Notice I am now installing openssl-dev and libffi-dev, then forcing twillio 6.0.0

Thanks again.

Qmando commented 7 years ago

Glad we could get this fixed. Sorry about the trouble! Changing library APIs and C extensions make it a little bit a of a nightmare sometimes.

I'm gonna try to move most of these to being optional.

anjan-cele commented 7 years ago

I am getting the same error as above:

Traceback (most recent call last): File "/usr/local/bin/elastalert-test-rule", line 9, in load_entry_point('elastalert==0.1.12', 'console_scripts', 'elastalert-test-rule')() File "build/bdist.linux-x86_64/egg/pkg_resources/init.py", line 560, in load_entry_point File "build/bdist.linux-x86_64/egg/pkg_resources/init.py", line 2648, in load_entry_point File "build/bdist.linux-x86_64/egg/pkg_resources/init.py", line 2302, in load File "build/bdist.linux-x86_64/egg/pkg_resources/init.py", line 2308, in resolve File "/usr/local/lib/python2.7/dist-packages/elastalert-0.1.12-py2.7.egg/elastalert/test_rule.py", line 20, in import elastalert.config File "/usr/local/lib/python2.7/dist-packages/elastalert-0.1.12-py2.7.egg/elastalert/config.py", line 8, in import alerts File "/usr/local/lib/python2.7/dist-packages/elastalert-0.1.12-py2.7.egg/elastalert/alerts.py", line 26, in from twilio.base.exceptions import TwilioRestException ImportError: No module named base.exceptions

I installed twilio == 6.0.0 but not resolved the issue.

I have one python installed in my system.

I am not able to run this command as mentioned above i.e RUN apk add --update \ ca-certificates \ openssl-dev \ libffi-dev \ build-base \ && rm -rf /var/cache/apk/*

Install Elastalert.

RUN python setup.py install && \ pip install -e . && \ pip uninstall twilio --yes && \ pip install twilio==6.0.0

it is telling like 👍 apk : Command not found.

Can anybody help me in resolving @Qmando;@gjobin

Qmando commented 7 years ago

@anjan-cele

apk is for Alpine linux. If you are using Ubuntu (debian) you should use apt-get instead.

sudo apt-get update
sudo apt-get install libssl-dev libffi-dev

"I installed twilio == 6.0.0 but not resolved the issue." If this were true you would not be getting that exception. Try typing $ python -c "import twilio;print twilio.__version__" How did you install it?

anjan-cele commented 7 years ago

Hi @Qmando

apt-get worked for me. Thanks for suggesting.

But I am facing a new issue when I am testing the rule i.e

$ elastalert-test-rule example_rules/example_frequency.yaml

Following error I am getting - Successfully loaded Example frequency rule

WARNING:elasticsearch:GET http://localhost:14900/ [status:N/A request:0.002s] Traceback (most recent call last): File "build/bdist.linux-x86_64/egg/elasticsearch/connection/http_requests.py", line 75, in perform_request timeout=timeout or self.timeout) File "/usr/local/lib/python2.7/dist-packages/requests-2.13.0-py2.7.egg/requests/sessions.py", line 609, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python2.7/dist-packages/requests-2.13.0-py2.7.egg/requests/adapters.py", line 487, in send raise ConnectionError(e, request=request) ConnectionError: HTTPConnectionPool(host='localhost', port=14900): Max retries exceeded with url: / (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f3ee37633d0>: Failed to establish a new connection: [Errno 111] Connection refused',)) WARNING:elasticsearch:GET http://localhost:14900/ [status:N/A request:0.001s]

Can you tell me what is the issue here. Thanks

Qmando commented 7 years ago

You didn't change the default es_host and es_port.

anjan-cele commented 7 years ago

Error solved but email not working. Does elastalert only work with postfix? Because that isn't going to be able to send mail outside its local server. Is there an option to connect to an SMTP server or Exchange server?

Thanks

Qmando commented 7 years ago

http://elastalert.readthedocs.io/en/latest/ruletypes.html#email