Switch to OpenSearch
This commit is contained in:
parent
3973413f51
commit
c516bb9ca9
|
@ -7,7 +7,7 @@ from pycoingecko import CoinGeckoAPI
|
||||||
from forex_python.converter import CurrencyRates
|
from forex_python.converter import CurrencyRates
|
||||||
import urllib3
|
import urllib3
|
||||||
import logging
|
import logging
|
||||||
from elasticsearch import Elasticsearch
|
from opensearchpy import OpenSearch
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# Project imports
|
# Project imports
|
||||||
|
@ -17,7 +17,7 @@ import util
|
||||||
# TODO: secure ES traffic properly
|
# TODO: secure ES traffic properly
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
|
|
||||||
tracer = logging.getLogger("elasticsearch")
|
tracer = logging.getLogger("opensearch")
|
||||||
tracer.setLevel(logging.CRITICAL)
|
tracer.setLevel(logging.CRITICAL)
|
||||||
tracer = logging.getLogger("elastic_transport.transport")
|
tracer = logging.getLogger("elastic_transport.transport")
|
||||||
tracer.setLevel(logging.CRITICAL)
|
tracer.setLevel(logging.CRITICAL)
|
||||||
|
@ -38,12 +38,26 @@ class Money(util.Base):
|
||||||
self.cr = CurrencyRates()
|
self.cr = CurrencyRates()
|
||||||
self.cg = CoinGeckoAPI()
|
self.cg = CoinGeckoAPI()
|
||||||
if settings.ES.Enabled == "1":
|
if settings.ES.Enabled == "1":
|
||||||
self.es = Elasticsearch(
|
# self.es = Elasticsearch(
|
||||||
f"https://{settings.ES.Host}:9200",
|
# f"https://{settings.ES.Host}:9200",
|
||||||
|
# verify_certs=False,
|
||||||
|
# basic_auth=(settings.ES.Username, settings.ES.Pass),
|
||||||
|
# # ssl_assert_fingerprint=("6b264fd2fd107d45652d8add1750a8a78f424542e13b056d0548173006260710"),
|
||||||
|
# ca_certs="certs/ca.crt",
|
||||||
|
# )
|
||||||
|
# TODO: implement ca certs https://opensearch.org/docs/latest/clients/python/
|
||||||
|
auth = (settings.ES.Username, settings.ES.Pass)
|
||||||
|
self.es = OpenSearch(
|
||||||
|
hosts=[{"host": settings.ES.Host, "port": 9200}],
|
||||||
|
http_compress=False, # enables gzip compression for request bodies
|
||||||
|
http_auth=auth,
|
||||||
|
# client_cert = client_cert_path,
|
||||||
|
# client_key = client_key_path,
|
||||||
|
use_ssl=True,
|
||||||
verify_certs=False,
|
verify_certs=False,
|
||||||
basic_auth=(settings.ES.Username, settings.ES.Pass),
|
ssl_assert_hostname=False,
|
||||||
# ssl_assert_fingerprint=("6b264fd2fd107d45652d8add1750a8a78f424542e13b056d0548173006260710"),
|
ssl_show_warn=False,
|
||||||
ca_certs="certs/ca.crt",
|
# a_certs=ca_certs_path,
|
||||||
)
|
)
|
||||||
|
|
||||||
def run_checks_in_thread(self):
|
def run_checks_in_thread(self):
|
||||||
|
@ -73,7 +87,7 @@ class Money(util.Base):
|
||||||
cast["type"] = msgtype
|
cast["type"] = msgtype
|
||||||
cast["ts"] = str(datetime.now().isoformat())
|
cast["ts"] = str(datetime.now().isoformat())
|
||||||
cast["xtype"] = "tx"
|
cast["xtype"] = "tx"
|
||||||
self.es.index(index=settings.ES.Index, document=cast)
|
self.es.index(index=settings.ES.Index, body=cast)
|
||||||
|
|
||||||
def lookup_rates(self, platform, ads, rates=None):
|
def lookup_rates(self, platform, ads, rates=None):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue