Last active
February 28, 2023 04:15
-
-
Save gileri/8f68e5f837bdd42e404522bf6eb40352 to your computer and use it in GitHub Desktop.
Cloudwatch logs length test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
from time import time, sleep | |
import boto3 | |
LOG_STREAM = str(int(time())) | |
LOG_GROUP = "CHANGEME" | |
cwl = boto3.client("logs") | |
cwl.create_log_stream( | |
logGroupName=LOG_GROUP, | |
logStreamName=LOG_STREAM, | |
) | |
def log_event(size: int, event_count: int): | |
try: | |
cwl.put_log_events( | |
logGroupName=LOG_GROUP, | |
logStreamName=LOG_STREAM, | |
logEvents=[ | |
{ | |
"timestamp": int(time()), | |
"message": 'a' * int(size / event_count), | |
} | |
for i in range(event_count) | |
] | |
) | |
print(f"Success with size {int(size / event_count)} across {event_count} events") | |
return True | |
except Exception as e: | |
print(f"Failed with size {int(size / event_count)} across {event_count} events: {e}") | |
return False | |
log_event(256 * 1024, 2) | |
size_sub = 10 | |
while True: | |
if not log_event(256 * 1024 - size_sub, 1): | |
size_sub += 1 | |
sleep(1) | |
continue | |
break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Success with size 131072 across 2 events | |
Failed with size 262134 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262160 bytes exceeds limit of 262144 | |
Failed with size 262133 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262159 bytes exceeds limit of 262144 | |
Failed with size 262132 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262158 bytes exceeds limit of 262144 | |
Failed with size 262131 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262157 bytes exceeds limit of 262144 | |
Failed with size 262130 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262156 bytes exceeds limit of 262144 | |
Failed with size 262129 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262155 bytes exceeds limit of 262144 | |
Failed with size 262128 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262154 bytes exceeds limit of 262144 | |
Failed with size 262127 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262153 bytes exceeds limit of 262144 | |
Failed with size 262126 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262152 bytes exceeds limit of 262144 | |
Failed with size 262125 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262151 bytes exceeds limit of 262144 | |
Failed with size 262124 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262150 bytes exceeds limit of 262144 | |
Failed with size 262123 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262149 bytes exceeds limit of 262144 | |
Failed with size 262122 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262148 bytes exceeds limit of 262144 | |
Failed with size 262121 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262147 bytes exceeds limit of 262144 | |
Failed with size 262120 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262146 bytes exceeds limit of 262144 | |
Failed with size 262119 across 1 events: An error occurred (InvalidParameterException) when calling the PutLogEvents operation: Log event too large: 262145 bytes exceeds limit of 262144 | |
Success with size 262118 across 1 events |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment