in 04_EdgeApplication/report/lambda_ingest_logs_elasticsearch.py [0:0]
def put_record(record, type):
base_url = elastic_url
path = '/wind_turbine_%s/data' % type
url = base_url + path
header={'Content-type': 'application/json'}
try:
data = json.dumps(record)
req = urllib.request.Request(url=url, headers=header, method='POST', data=data.encode('utf-8') )
res = urllib.request.urlopen(req, timeout=5)
except Exception as e:
print(record, type, e)