我在执行以下python脚本时遇到问题。它工作了一段时间,后来开始给我一些问题。 下面是脚本及其输出。
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))
以下是我得到的错误。
[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']:
我实际上是从Docker容器运行此脚本的。下面是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"]