Skip to content

Commit

Permalink
Add new setting to configure batch sizes for Beats transport
Browse files Browse the repository at this point in the history
Closes #93.
  • Loading branch information
eht16 committed Apr 13, 2024
1 parent 6c60c27 commit be6e30e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
11 changes: 11 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ for easy modification.
*Default*: ``50``


``constants.QUEUED_EVENTS_BEATS_BATCH_SIZE``

Maximum number of events to be sent to Logstash in one batch when using the Beats transport,
each batch of events is sent using the same connection and can be considered as a kind
of transaction. Should be smaller than `QUEUED_EVENTS_BATCH_SIZE`.

*Type*: ``integer``

*Default*: ``25``


``constants.DATABASE_EVENT_CHUNK_SIZE``

Maximum number of events to be updated within one SQLite statement
Expand Down
4 changes: 4 additions & 0 deletions logstash_async/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class Constants:
QUEUED_EVENTS_FLUSH_COUNT = 50
# maximum number of events to be sent to Logstash in one batch (i.e. using a single connection)
QUEUED_EVENTS_BATCH_SIZE = 50
# maximum number of events to be sent to Logstash in one batch when using the Beats transport,
# each batch of events is sent using the same connection and can be considered as a kind
# of transaction. Should be smaller than QUEUED_EVENTS_BATCH_SIZE.
QUEUED_EVENTS_BEATS_BATCH_SIZE = 25
# maximum number of events to be updated within one SQLite statement
DATABASE_EVENT_CHUNK_SIZE = 750
# timeout in seconds to "connect" (i.e. open) the SQLite database
Expand Down
4 changes: 1 addition & 3 deletions logstash_async/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ def _send_via_socket(self, data):

class BeatsTransport:

_batch_size = 10

# ----------------------------------------------------------------------
def __init__( # pylint: disable=too-many-arguments
self,
Expand Down Expand Up @@ -264,7 +262,7 @@ def close(self):
def send(self, events, use_logging=False):
client = pylogbeat.PyLogBeatClient(use_logging=use_logging, **self._client_arguments)
with client:
for events_subset in ichunked(events, self._batch_size):
for events_subset in ichunked(events, constants.QUEUED_EVENTS_BEATS_BATCH_SIZE):
client.send(events_subset)


Expand Down

0 comments on commit be6e30e

Please sign in to comment.