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

AWS ElasticSerch #32

Closed
yasin-amadmia-mck opened this issue Nov 5, 2017 · 2 comments
Closed

AWS ElasticSerch #32

yasin-amadmia-mck opened this issue Nov 5, 2017 · 2 comments

Comments

@yasin-amadmia-mck
Copy link

Hi, Trying this

import logging
from cmreslogging.handlers import CMRESHandler

handler = CMRESHandler(hosts=[{'host': 'http://search-xxxx.es.amazonaws.com', 'port': 80}],
                           auth_type=CMRESHandler.AuthType.AWS_SIGNED_AUTH,
                           use_ssl=False,
                           verify_ssl =False,
                           aws_secret_key='xxxxx',
                           aws_access_key='xxxx',
                           aws_region='eu-west-2',
                           es_index_name="my_python_index")
log = logging.getLogger("PythonTest")
log.setLevel(logging.INFO)
log.addHandler(handler)

The above fails with error

Traceback (most recent call last):
  File "/Users/x/PycharmProjects/elasticsearch/test.py", line 11, in <module>
    es_index_name="my_python_index")
  File "/Users/x/PycharmProjects/VirtualEnvironments/elasticsearch/lib/python2.7/site-packages/cmreslogging/handlers.py", line 194, in __init__
    'host_ip': socket.gethostbyname(socket.gethostname())})
socket.gaierror: [Errno 8] nodename nor servname provided, or not known
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1666, in shutdown
    h.flush()
  File "/Users/x/PycharmProjects/VirtualEnvironments/elasticsearch/lib/python2.7/site-packages/cmreslogging/handlers.py", line 283, in flush
    if self._timer is not None and self._timer.is_alive():
AttributeError: 'CMRESHandler' object has no attribute '_timer'
Error in sys.exitfunc:
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 1666, in shutdown
    h.flush()
  File "/Users/x/PycharmProjects/VirtualEnvironments/elasticsearch/lib/python2.7/site-packages/cmreslogging/handlers.py", line 283, in flush
    if self._timer is not None and self._timer.is_alive():
AttributeError: 'CMRESHandler' object has no attribute '_timer'
@cmanaha
Copy link
Owner

cmanaha commented Nov 16, 2017

Will check and try to reproduce as soon as I have some time. Anyone interested on getting this fixed, please feel free to send a PR.

@geek876
Copy link

geek876 commented Nov 19, 2017

This is due to the fact that gethostbyname() raises error if the hostname is not resolvable either via DNS or via localhosts file.

PR: #34

@cmanaha cmanaha closed this as completed Nov 1, 2018
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

3 participants