You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
765 B
23 lines
765 B
from datetime import datetime
|
|
from elasticsearch import Elasticsearch
|
|
from wowstash import config
|
|
|
|
|
|
def send_es(data):
|
|
if getattr(config, 'ELASTICSEARCH_ENABLED', False):
|
|
try:
|
|
es = Elasticsearch(
|
|
[getattr(config, 'ELASTICSEARCH_HOST', 'localhost')]
|
|
)
|
|
now = datetime.utcnow()
|
|
index_ts = now.strftime('%Y%m%d')
|
|
data['datetime'] = now
|
|
es.index(
|
|
index="{}-{}".format(
|
|
getattr(config, 'ELASTICSEARCH_INDEX_NAME', 'wowstash'),
|
|
index_ts
|
|
), body=data)
|
|
except Exception as e:
|
|
print('Could not capture event in Elasticsearch: ', e)
|
|
pass # I don't really care if this logs...
|