add label to docker network and convert timestamps for elastic (#2009)
Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
parent
70c0d51a0f
commit
d4ecd3462d
3
Makefile
3
Makefile
|
@ -49,6 +49,9 @@ dev-env: stop-dev build-images poetry-i be-poetry-i be-db-clean fe-npm-i
|
|||
start-dev: stop-dev
|
||||
$(DOCKER_COMPOSE) up -d
|
||||
|
||||
start-event-stream:
|
||||
$(DOCKER_COMPOSE) up -d event-stream
|
||||
|
||||
stop-dev:
|
||||
$(DOCKER_COMPOSE) down
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ KIBANA_PASSWORD ?= kibana
|
|||
|
||||
|
||||
net-start:
|
||||
docker network create $(NETWORK) || true
|
||||
docker network create --label com.docker.compose.network=default $(NETWORK) || true
|
||||
|
||||
net-stop:
|
||||
docker network rm $(NETWORK) || true
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from datetime import datetime
|
||||
import pytz
|
||||
import json
|
||||
import os, os.path
|
||||
import socket
|
||||
|
@ -42,6 +44,13 @@ def init_urllib():
|
|||
urllib.request.install_opener(opener)
|
||||
|
||||
def send_event(event):
|
||||
if 'timestamp' in event:
|
||||
timestamp_value = event['timestamp']
|
||||
# if timestamp is an integer or a float (any numeric type), convert to a iso8601 string so that elastic will index it as a date
|
||||
if isinstance(timestamp_value, (int, float)):
|
||||
utc_time = datetime.fromtimestamp(timestamp_value, tz=pytz.UTC)
|
||||
event['timestamp'] = utc_time.isoformat()
|
||||
|
||||
try:
|
||||
post_body = json.dumps(event).encode("utf-8")
|
||||
request = urllib.request.Request(ELASTICSEARCH_URL)
|
||||
|
|
Loading…
Reference in New Issue