Skip to content

Commit

Permalink
don't print we have a sample now
Browse files Browse the repository at this point in the history
  • Loading branch information
gvelez17 committed May 22, 2024
1 parent ddbd678 commit c7c698a
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions logs-to-tsdb/kinesis-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import re
import psycopg2.extras
from base64 import b64decode
from base64 import b64decode, b64encode
from datetime import datetime, timezone
from pprint import pprint

Expand Down Expand Up @@ -34,7 +34,6 @@ def handler(event, context):
batched = []

for record in event['Records']:
pprint(record)
# Decode the Kinesis data
payload = b64decode(record['kinesis']['data']).decode('utf-8')
data = json.loads(payload)
Expand Down Expand Up @@ -64,3 +63,28 @@ def handler(event, context):
conn.close()

print("Kinesis pipe done, check the db")

# For testing locally
if __name__ == "__main__":

# Mock event and context for testing locally
event = {
"Records": [
{
"kinesis": {
"data": b64encode(json.dumps({
"logEvents": [
{
"timestamp": 1625239073000,
"message": "your log message"
}
]
}).encode('utf-8')).decode('utf-8')
}
}
]
}
pprint(event)
context = {}

handler(event, context)

0 comments on commit c7c698a

Please sign in to comment.