Skip to content

Commit

Permalink
Merge pull request #3 from 3box/fix/update-backfill
Browse files Browse the repository at this point in the history
update backfill for no did
  • Loading branch information
gvelez17 authored Jun 28, 2024
2 parents 6d7a8fa + 2a1da5f commit f175897
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 34 deletions.
4 changes: 2 additions & 2 deletions logs-to-tsdb/backfill/get-all-days.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def get_query_results(query_id, filename):
def main():
log_group = "/ecs/ceramic-prod-cas"

start_date_str = "2024-05-22 23:59:00"
end_date_str = "2024-05-23 08:00:00"
start_date_str = "2024-06-17 23:59:00"
end_date_str = "2024-06-26 00:00:00"
start_date = datetime.strptime(start_date_str, "%Y-%m-%d %H:%M:%S").replace(tzinfo=timezone.utc)
end_date = datetime.strptime(end_date_str, "%Y-%m-%d %H:%M:%S").replace(tzinfo=timezone.utc)

Expand Down
7 changes: 6 additions & 1 deletion logs-to-tsdb/backfill/munge2.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,10 @@
newl['awslogs']['data'] = subprocess.run(['base64', '{}.gz'.format(fname)], capture_output=True, text=True).stdout.strip()

with open('ready_{}.json'.format(logid), 'w') as f:
json.dump(newl, f)
json.dump(newl, f)
# os.system('python-lambda-local -f handler ../logs-lambda.py ready_{}.json --environment DB_HOST={} DB_PASSWORD={} --timeout 20'.format(
# logid,
# os.environ['DB_HOST'],
# os.environ['DB_PASSWORD']
# ))
os.system('python-lambda-local -f handler ../logs-lambda.py ready_{}.json --timeout 20'.format(logid))
4 changes: 2 additions & 2 deletions logs-to-tsdb/logs-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def handler(event, context):

data = json.loads(match.group(1))

batched.append((ts, data['cid'], data['did'], data.get('model'), data.get('family'), data.get('stream'), data.get('origin'), data.get('cacao'), data.get('cap_cid')))
batched.append((ts, data['cid'], data.get('did'), data.get('model'), data.get('family'), data.get('stream'), data.get('origin'), data.get('cacao'), data.get('cap_cid')))

# Insert logs into TimescaleDB
insert_query = "INSERT INTO cas_log_data (timestamp, cid, did, model, family, stream, origin, cacao, cap_cid) VALUES %s"
insert_query = "INSERT INTO cas_log_data (timestamp, cid, did, model, family, stream, origin, cacao, cap_cid) VALUES %s on CONFLICT DO NOTHING"

print("Inserting {} rows including {}".format(len(batched), batched[0]))

Expand Down
23 changes: 0 additions & 23 deletions logs-to-tsdb/sample.json

This file was deleted.

1 change: 0 additions & 1 deletion logs-to-tsdb/sample_base64.txt

This file was deleted.

5 changes: 0 additions & 5 deletions logs-to-tsdb/sample_test.json

This file was deleted.

0 comments on commit f175897

Please sign in to comment.