start capturing events into elasticsearch and say so in privacy page
parent
875897f067
commit
86fd1ecbcc
@ -0,0 +1,21 @@
|
||||
from datetime import datetime
|
||||
from elasticsearch import Elasticsearch
|
||||
from wowstash import config
|
||||
|
||||
|
||||
def send_es(data):
|
||||
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...
|
Loading…
Reference in New Issue