Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log-processor: lambda failing because of missing variable 'batch_size' #242

Closed
jkrivas opened this issue Jan 22, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@jkrivas
Copy link

jkrivas commented Jan 22, 2024

Describe the bug

Using version 2.1.1 of solution for sending AWS WAF logs from S3 to OpenSearch.

When trying to upload a bigger batch of logs, it gets error 413 (too big batches sent). It then should automatically adjust batch size, however it fails with error that variable batch_size does not exist

Expected Behavior

For it to successfully send logs to OpenSearch.

Current Behavior

[INFO] PUT aws-waf/_bulk
[INFO] --> bulk_load response code 413
[ERROR] NameError: name 'batch_size' is not defined
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 44, in lambda_handler
    raise e
  File "/var/task/lambda_function.py", line 38, in lambda_handler
    getattr(sys.modules[__name__], func_name)(event)
  File "/var/task/lambda_function.py", line 84, in parse_sqs_event
    sqs.process_event(event)
  File "/var/task/event/event_parser.py", line 452, in process_event
    total, failed_records = self._bulk(records)
  File "/var/task/event/event_parser.py", line 124, in _bulk
    return idx_svc.bulk_load_idx_records(self._process_by_plugins(records))
  File "/var/task/idx/idx_svc.py", line 333, in bulk_load_idx_records
    self.adjust_bulk_batch_size()
  File "/var/task/idx/idx_svc.py", line 351, in adjust_bulk_batch_size
    if batch_size >= 4000:

Reproduction Steps

Try to load a big batch of logs to OpenSearch so that function adjust_bulk_batch_size gets invoked

Possible Solution

It seems it tries to reference global variable batch_size which is not defined. After manually defining the variable with

batch_size = int(os.environ.get("BULK_BATCH_SIZE", DEFAULT_BULK_BATCH_SIZE))

it started working.

Additional Information/Context

No response

Solution Version

2.1.1

AWS Region. e.g., us-east-1

No response

Other information

No response

@jkrivas jkrivas added the bug Something isn't working label Jan 22, 2024
@JoeShi
Copy link
Contributor

JoeShi commented Feb 6, 2024

will be fix in v2.2

owenCCY pushed a commit to owenCCY/centralized-logging-with-opensearch that referenced this issue Mar 16, 2024
This was referenced Mar 17, 2024
@evalzy evalzy closed this as completed Mar 19, 2024
@evalzy
Copy link

evalzy commented Mar 19, 2024

Fixed in V2.1.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

No branches or pull requests

4 participants