Reduce Processor

Description

The Reduce processor takes multiple log input events and combines them into a single log event based on specified criteria.

Use

Reduce will combine many events into one over a window of time. This is useful for retaining event fidelity, but eliminating unnecessary or duplicate fields that do not need to be stored.

Reduce can use one or more Group By fields to determine when to perform an operation. For example, you could use a session_Id field value that is consistent across many event messages as criteria for putting those events into a single group to be merged. You may specify more than one Group By field, in which case each message with a unique combination of those field values opens a separate group of events to be merged together.

You can configure how fields are handled on a per-field basis with a merge strategy. If you don't specify the merge strategy, a default merge strategy for each reduced event follows this pattern:

  • String fields - The first value is kept while successive ones are discarded
  • Number fields - The values are summed, and that result becomes the value of the field

Configuration

There are three options to configure for this processor. Note that two of these can have any number of values specified.

The Reduce processor has a maximum window of 2 hrs or 7200000 milliseconds.

OptionDescriptionExample
DurationThe total window of time over which to run the reduction3000ms (default)
Group ByThe incoming event fields to group. If none are specified, all events are combined..level
Max EventsThe maximum number of events to collect before flushing the cache, even if the duration time has not been reached10
Merge StrategyDetermines how the contents of a specified field will be treated when added to the combined event.

Merge Strategy Options

The merge options define how the fields will be combined. Note that certain strategies require numeric values in order to function.

OptionDescriptionRequired Input Type
ArrayAppend each value to an array.Any
Smallest ArrayKeep the shortest array detectedArray
Largest ArrayKeep the longest array detected.Array
Unique ArrayCreate an array of all unique values.Any
Join with SpaceConcatenate each string value and separate with a space.String
Join with New LineConcatenate each string value and add to a new line.String
JoinConcatenate each string value together with nothing betweenString
Keep firstDiscard every value except the first one detected.Any
Keep lastDiscard every value except the last one detected.Any
Min ValueKeep the smallest numeric value detected.Numeric
Max ValueKeep the largest numeric value detected.Numeric
SumAdd all values together into a single summed value.Numeric

Flush conditions

Flush conditions define the logical parameters to determine the start or stop of the Reducing behavior. Flush conditions work on the event context, so the conditions apply to the latest event received, not to the merged event.

OptionDescription
starts_whenDefine the logical conditions on when to start reducing. Reduce will not start summarizing events until the conditions are achieved, and thereafter reduce based on the defined grouping conditions until the time window has been achieved.
ends_whenDefine the logical conditions on when to stop reducing and flush the buffer, egressing the summarized event so far. Reduce will stop summarizing the events for a specific group when the latest event matches the defined conditions. The reduce operation will stop before the maximum window time is reached.

Examples

Reducing a firewall event

Given a typical AWS firewall TCP event, we want to summarize multiple event messages into a single message.

JSON
Copy

The group by conditions leverage the following fields:

  1. src_ip
  2. src_port
  3. dest_ip
  4. dest_port

The merge strategy:

  • Retains the last timestamp ts, event_dest_port, event_src_port
  • Keeps the unique array of the tcp values
  • All other fields are using the default merge strategies, which sums the bytes and packets and keeps the first values for all other strings

In this case the 2 events will be combined as follows with the default merge:

JSON
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
  Last updated