in lambda/api/lambda_metrics.py [0:0]
def get_metrics(event):
"""
Download the s3 file contents, and enuemrage json lienes to extract metrics
"""
metrics = []
for record in event["Records"]:
bucket = record["s3"]["bucket"]["name"]
key = unquote_plus(record["s3"]["object"]["key"])
obj = s3.Object(bucket, key)
with gzip.GzipFile(fileobj=obj.get()["Body"]) as gzipfile:
content = gzipfile.read()
buf = io.BytesIO(content)
line = buf.readline()
while line:
metrics.append(json.loads(line))
line = buf.readline()
return metrics