Document toolboxDocument toolbox

Count Window Collector

Description

This unit is a Processor unit type.

This unit keeps events in memory until a certain number of events is received. It can be configured to either use a global window for all events or to create a new window for each key.

An event comes in through the in port. The event is stored in the window associated with the event key. If the size of the window reaches the threshold, all events are released.
Windowed events are sent to the out output port.
If an error occurs, the input events are enriched with standard error fields and sent to the error port.

Configuration

After dragging this unit into the Flow canvas, double-click it to access its configuration options. The following table describes the configuration options of this unit:

TabFieldDescription

General

NameEnter a name for the unit. It must start with a letter, and cannot contain spaces. Only letters, numbers, and underscores are allowed.
Key field(s)Enter the name of the input event field(s) containing key(s).
SizeThe number of events in a window. Must be greater than 1.
Purge size

The number of events to purge from the window when it is considered complete. If it's equal to "size", a tumbling window is used. If it's smaller, a sliding window is used.

Key(s) fieldEnter a name for the output event field containing key(s).
Window field

Enter a name for the output event field containing the window list. 

Size fieldEnter a name for the output event field containing the window size.

Input ports

PortDescription
in All events enter through this port.

Output ports


PortDescription
outOutputs events properly stored.
errorSignals when an error occurs. Outputs input events enriched with standard error fields.

Example

In this example, we wish to accumulate five 404 status codes and send them via email when the threshold has been met to alert of the error.

To do this, we add a Tick unit to fire the request every time we need it. Then, we link it to the input port of the Count Window Collector unit and join its output port to an Email Sink unit to send it to the required recipients. 

In the Tick unit, configure the key field to return the status code every time a 404 code is detected.

In the Count Window Collector properties, specify the key field that coincides with the Tick unit, in this case the 404StatusCode field earlier configured. Add the purge size as the same as the size field, in this case 5, to use a tumbling window.

In the Email Sink unit properties, you must specify the required subject and message of the emails and the list of addresses to which you want to notify.

You can try this flow by downloading this JSON file and uploading it to your domain using the Import option.