-->

issues with aws elasticsearch-curator

2019-08-25 03:06发布

问题:

I am having issues with executing below python script. it was working for couple of time and later it started giving me issues. below is the script and its output.

import boto3
from requests_aws4auth import AWS4Auth
from elasticsearch import Elasticsearch, RequestsHttpConnection
import curator

host = 'search-xxxx-xxxxx-xxxxxxxxxxx-xxxxxxxxxx-xxxxxxxxxxxxxxxxxx.us-east-1.es.amazonaws.com' # For example, search-my-domain.region.es.amazonaws.com
region = 'us-east-1' # For example, us-west-1
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)

# Build the Elasticsearch client.
es = Elasticsearch(
    hosts = [{'host': host, 'port': 443}],
    http_auth = awsauth,
    use_ssl = True,
    verify_certs = True,
    connection_class = RequestsHttpConnection
)

index_list = curator.IndexList(es)

# Filters by age, anything with a time stamp older than 30 days in the index name.
index_list.filter_by_age(source='name', direction='older', timestring='%Y.%m.%d', unit='days', unit_count=67)
print("Found %s indices to delete" % len(index_list.indices))

below is the error that I am getting.

[root@8bd6e182566c ~]# python -d testpy.py
Traceback (most recent call last):
  File "testpy.py", line 21, in <module>
    index_list = curator.IndexList(es)
  File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 31, in __init__
    self.__get_indices()
  File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 72, in __get_indices
    self._get_index_stats()
  File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 149, in _get_index_stats
    iterate_over_stats(stats_result)
  File "/usr/lib/python2.7/site-packages/curator/indexlist.py", line 121, in iterate_over_stats
    for index in stats['indices']:

I am actually running this script from a docker container. and below is the dockerfile.

FROM alpine:3.7
RUN apk --no-cache add bash python py-setuptools py-pip gcc libffi py-cffi python-dev libffi-dev py-openssl musl-dev linux-headers openssl-dev libssl1.0 
RUN pip install elasticsearch-curator==5.6.0 && \
    pip install boto3==1.9.59 && \
    pip install requests-aws4auth==0.9 && \
    pip install cryptography && \
    sed -i '/import sys/a urllib3.contrib.pyopenssl.inject_into_urllib3()' /usr/bin/curator && \
    sed -i '/import sys/a import urllib3.contrib.pyopenssl' /usr/bin/curator && \
    sed -i '/import sys/a import urllib3' /usr/bin/curator
ENTRYPOINT ["/usr/bin/curator"]