Event Pattern Authoring
The majority of pattern detection logic is configured in the event pattern view. In this environment, you define how to find matches from incoming data via elements, either by themselves, or in relation with other elements by means of constraints. Once a pattern is detected, outcomes are used to produce output data based on the input data or computational results of the input data.
Working with Elements
An element is a unit of pattern detection logic that defines what parts of the incoming data constitute a match. In other words, elements tell the system what kinds of things to look for in the data. For more information about elements, see Model Artifacts.
Creating Elements
To create an element:
- In the tool palette, click the Element (⬭) icon.
- Click the event type to associate with the new element. Click New Event Type to create new event types, and then follow the instructions in Creating New Event Types.
- Click any open space in the diagramming area to place the element.
- In the details panel, edit the element’s properties as needed. For more information, see Editing Elements.
Elements may also be created directly on the canvas as follows:
- Right-click any empty space in the canvas.
- In the selection menu, click Add Element.
- In the dialog, select an event type. To create a new event type, click New, then follow the instructions in Creating New Event Types.
Depending on the source of the input data, elements in the event pattern view may have differently shaded colors:
- An element associated with a raw event type is deep blue.
- An element associated with a derived event type (that is, one that comes from an output of a lower-level event pattern) is brighter blue.
Editing Elements
When an element is selected in the event pattern view, its information is displayed in the details panel, where the element's details can be viewed and modified as needed.
To edit an element:
- In the diagramming area, click the element to edit.
- In the details panel, click the Contents tab if it is not already selected.
- Edit the element's details as necessary:
- Under Attributes:
- From the Event Types dropdown menu, select the event type to modify the event type associated with the element.
- In the Alias field, enter an alias for labeling the element. (It is recommended that the alias describe the element's unique role in its event pattern that differentiates it from other elements using the same event type.)
- In the Min field, specify the minimum number of events the element must receive.
- In the Max field, specify the maximum number of events the element must receive.
- Under Time to Live, define an expiration period for the element (i.e., how long it should exist in the system before being discarded) if needed:
- Click +. The Create Time-To-Live dialog opens. (The Create Time-To-Live dialog is also accessible by right-clicking an element and selecting Add Time to Live from the context menu.)
- In the Time Value field, enter a number indicating how long the element should remain valid.
- From the Unit Type dropdown menu, select the appropriate unit of time for the specified time value.
- Check the Apply to Matched Events checkbox to drop any matched records after the configured time-to-live period. Leave it unchecked to let matched records persist after the configured time-to-live period.
- Click Create to create the expiration period, or Cancel to discard it.
- Edit the expiration period by changing the field values, if needed.
- Click the Delete (trash can) icon to clear the entered values, if necessary.
- Under the Event Type section (which uses the name of the event type selected for the element):
- Click the pencil (✎) icon to edit the details.
- Follow the procedure in Editing Event Types.
- Under Attributes:
Working with Outcomes
An outcome is a unit of pattern detection logic that represents output data. In other words, once the system finds a pattern established in an element, an outcome tells the system what to do after that discovery. For more information about outcomes, see Model Artifacts.
Creating Outcomes
To create an outcome:
- In the tool palette, click the Outcome (▭) icon.
- Select the event type to associate with the new outcome. If a new event type should be created for the outcome, follow the process in Creating New Event Types.
- Click any open space in the diagramming area to place the outcome.
- In the details panel, edit the outcome’s properties as needed. For more information, see Editing Outcomes.
Outcomes may also be created directly on the canvas as follows:
- Right-click any empty space in the canvas.
- In the selection menu, click Add Outcome.
- In the dialog, select an event type. If a new event type should be created, click New, then follow the instructions in Creating New Event Types.
Editing Outcomes
When an outcome is selected in the event pattern view, its information is displayed in the details panel, where the outcome's details can be viewed and modified as needed.
To edit an outcome:
- In the diagramming area, click an outcome to edit.
- In the details panel, click the Content tab if it is not already selected.
- Edit the outcome’s details as needed:
- Under Attributes:
- Under Sources, click a source to edit its details. For more information, see Editing Elements.
- Under Computations, click a computation to check its details. Click the Delete (trash can) icon beside a computation to delete it. For more information about computations, see Built-In Computation Functions.
- Under Risk, choose the appropriate risk type:
- If the risk factors (elements) are independent from one another, select Weighted to assign a weight to each element.
- If the risk factors (elements) are dependent upon one another, select Bayesian to specify the conditions used to compute risk.
- Under Batch Output, click the Enable Batch Output toggle to enable batch output if desired. (By default, the toggle is set to "Off.") For more information, see Configuring Batch Output.
- Under the Outcome section (which uses the name of the selected outcome):
- Click the pencil (✎) icon to edit the details.
- Follow the procedure in Editing Event Types.
- Under Attributes:
Understanding Risk Types
Cogynt models can calculate risk based on two different approaches: weighted risk and Bayesian risk.
Risk types and weights are assigned when editing outcomes.
Using Weighted Risk
Weighted risk is used when the probability (weight) of elements or risk factors does not change based on the presence or absence of other risk factors. In other words, weighted risk is used for independent risk factors.
Suppose you want to calculate a population's cancer risk based on a number of personal and environmental factors, such as whether they smoke, whether they work with toxic chemicals, and so on. Since the risk of each factor remains more or less static, weighted risk would be useful for this model.
Using Bayesian Risk
Bayesian risk is modeled after the Bayes' theorem. It is used when the probability (weight) of elements or risk factors can change based on the presence or absence of other risk factors. In other words, Bayesian risk is used for dependent risk factors.
Suppose you want to calculate the risk of a wildfire occurring in a particular region. The wildfire risk might increase if the region has seen a drought, and it might decrease if there has been an unusual amount of rain. In this case, Bayesian risk would be useful to model the wildfire probability.
Configuring Batch Output
"Batching" refers to an increment of time during which the system waits to publish any updates for an event pattern until the next increment begins.
Batch output defines the increment of time during which the system listens to incoming data streams, and only publishes the data's updated (latest) state acquired during that interval.
The batch output interval refers to server time (time elapsed during the operation of the server), not data time (time specified in the data's timestamps or metadata).
To configure batch output for event patterns:
- In the diagramming area, click the desired event pattern's outcome.
- In the details panel, click the Contents tab if not already selected.
- Click the Batch Output section to expand it.
- Click the Enable Batch Output toggle to set it to "On".
- In the Time Value field, enter the interval of time that the output window should span.
- From the Unit Type dropdown menu, select the appropriate unit for the time value.
- Click outside of the details menu to save the changes.
Working with Constraints
A constraint is a condition placed upon an input event for an event pattern to be considered a match. For more information about constraints, see Model Artifacts.
Creating Constraints
To create a constraint:
- In the diagramming area, click an element.
- Click the Connection (🔀) button, then drag the line to another element.
- In the Create a Constraint dialog:
- For the first (green) element:
- Click the Fields dropdown menu.
- Select the appropriate field name. If the list is too long, type the first few characters of the field's name to narrow down the list.
- Click Computations if computations based on field values are needed to produce a result for comparison. For more information, see Constraint Computations Authoring.
- Repeat steps 3.i.a–3.i.c for the second (yellow) element.
- Click the Comparison Option dropdown menu to select a comparison option for the two elements.
- In the Offset field, if necessary, specify a value to add to the source event for the comparison. (For example, if you knew that all the source event's dates would be five minutes behind due to a server outage, you could use Offset to add five minutes to the source value.)
- In the Tolerance field, if necessary, specify a value to add and subtract from the source event to create a range of valid values for comparison operations. (For example, if you knew that the source event's dates would be either five minutes ahead or five minutes behind, and wanted to cover all possible dates within that range, then you could use Tolerance to establish this as the acceptable range.)
- For the first (green) element:
- Click OK to create the constraint, or click Cancel to discard it.
Selecting Constraints
Constraint options vary depending on the datatypes involved. For example, if a constraint is created between two scalar strings, the constraints are limited to "equal" and "not equal."
The available constraints are as follows:
- Contains – Checks whether one element is contained within the other.
- Count equal – Checks whether the number of elements in an array is equal to the specified number.
- Count greater than – Checks whether the number of elements in an array exceeds the specified number.
- Count greater than or equal – Checks whether the number of elements in an array exceeds or matches the specified number.
- Count less than – Checks whether the number of elements in an array is less than the specified number.
- Count less than or equal – Checks whether the number of elements in an array is less than or equal to the specified number.
- Count not equal – Checks whether the number of elements in an array does not match the specified number.
- Equal – Checks whether both elements have the same value.
- Greater than – Checks whether one element represents a greater number than the other.
- Greater than or equal – Checks whether one element represents a greater or equivalent number than the other.
- In network – Checks whether one element exists in the same network as the other.
- Inside – Checks whether one element is situated inside the other.
- Less than – Checks whether one element represents a lesser number than the other.
- Less than or equal – Checks whether one element represents a lesser or equivalent number than the other.
- Not equal – Checks whether the elements are not the same.
- Outside – Checks whether one element is situated outside the other.
The possible datatypes are as follows, and can be either scalars or arrays:
- Boolean – A true or false value.
- Date/Time – A datatype that represents a date and time together as a single data unit.
- Float – A floating point number (decimal value or fractional number).
- Geo Coordinate – A GeoJSON-formatted pair of numerical coordinates indicating a single geographical point.
- Geo Polygon – A GeoJSON-formatted set of coordinate pairs describing a geographical area.
- Integer – A whole number, such as 25 or -25.
- IP – A unique address that identifies a device on the internet or a local network.
- IP Range – A set of consecutive IP addresses.
- Null – An empty value.
- String – A sequence of (often alphabetical) characters.
- Unique ID (UUID) – An alphanumeric string for labeling information in a computer system.
- URL – An address for a unique resource on the Internet.
For certain Cogynt builds, several datatypes beginning with the prefix COG_
may be available. These datatypes represent Cogynt-level metadata or extra features that invoke particular Cogynt behaviors. The COG_
datatypes include:
- COG_confidence: The place where risk scores are published. Manually mapping values here allows bypassing risk tables if desired.
- COG_filter: A Boolean field that, if it receives
True
, publishes the event to the output topic. If it receivesFalse
, it suppresses the event instead. - COG_id: A unique identifier for items.
COG_id
only exists in input events, and cannot be overwritten from the UI. - COG_matches: The behavior of
COG_matches
varies depending on whether it is an input or output element:- As input: If the element or event type has a lexicon filter on it, then
COG_matches
produces an array of words that matches the lexicon. Similarly, for matched nodes, it lists the name of the lexicon node. - As output: If mapped to an outcome, words indicating lexicon matches are highlighted when shown in Cogynt Workstation.
- As input: If the element or event type has a lexicon filter on it, then
- COG_timestamp: An optional field. Datetime values can be mapped to
COG_timestamp
. When ingested, Cogynt Workstation interprets the mapped value to determine the timestamp used for denoting events in chronological order. (COG_timestamp
has no impact on how Authoring patterns behave.)
The constraints available for the various datatype combinations are outlined in the following tables.
Only valid datatype pairings are listed in the tables. If a pairing is not listed, then there are no constraints available for it.
The same constraints are available regardless of which datatype is the first and which is the second in the pairing.
Scalar-to-Scalar Constraints
First Datatype | Second Datatype | Available Constraints |
---|---|---|
Boolean | Boolean |
|
Date/Time | Date/Time |
|
Float | Float |
|
Geo Coordinate | Geo Coordinate |
|
Geo Coordinate | Geo Polygon |
|
Geo Polygon | Geo Polygon |
|
Integer | Integer |
|
IP | IP |
|
IP Range | IP |
|
IP Range | IP Range |
|
String | String |
|
Unique ID | Unique ID |
|
URL | URL |
|
Array-to-Array Constraints
First Datatype | Second Datatype | Available Constraints |
---|---|---|
Geo Coordinate | Geo Coordinate |
|
Geo Coordinate | Geo Polygon |
|
Geo Polygon | Geo Polygon |
|
Array-to-Scalar Constraints
First Datatype (Array) | Second Datatype (Scalar) | Available Constraints |
---|---|---|
Boolean | Boolean |
|
Boolean | Integer |
|
Date/Time | Date/Time |
|
Date/Time | Integer |
|
Float | Float |
|
Float | Integer |
|
Geo Coordinate | Geo Coordinate |
|
Geo Coordinate | Geo Polygon |
|
Geo Polygon | Geo Coordinate |
|
Geo Polygon | Geo Polygon |
|
Integer | Integer |
|
IP | Integer |
|
IP | IP Range |
|
String | Integer |
|
String | String |
|
Unique ID | Integer |
|
Unique ID | Unique ID |
|
URL | Integer |
|
URL | URL |
|
Editing Constraints
To edit a constraint:
- In the diagramming area, click a constraint to edit.
- In the details panel, click the Contents tab if it is not already selected.
- For the first (green) element:
- Click the Fields dropdown menu.
- Select the appropriate field name. If the list is too long, type the first few characters of the field’s name to narrow down the list.
- Click Computations if computations based on field values are needed to produce a result for comparison. For more information, see Constraint Computations Authoring.
- Repeat steps 3.i-3.iii for the second (yellow) element.
- Click the Comparison Option dropdown menu to a select a comparison option for the two elements.
- Click anywhere outside the details panel to save the changes.
Editing Groups
The only editable attribute of a group is its color.
Groups are a legacy feature in Cogynt, and no longer serve any necessary functions.
To change the color of a group:
- In the diagramming area, click the group to edit.
- In the details panel, click the Contents tab if it's not already selected.
- Click the color bar above the Members section.
- From the color palette, select the desired color.
- Click anywhere outside the color palette to close it and save the change.
For more information about groups, see Model Artifacts.
Working with Partitions
Partitions instruct the system to split and group the analysis by one or more fields.
Consider a pattern that analyzes a stream of bank transactions from a bank, containing the magnitude of position or negative flow of cash value and the bank account to which it pertains. The pattern computes the balance for each account.
In this case, a partition is set to the bank account field, so the system knows to compute a balance for each bank account, rather than treat the entire stream as a single bank account.
Creating Partitions
To create a partition for an event pattern:
- In the diagramming area, click an event pattern to give a partition.
- In the details panel, click the Contents tab if it is not already selected.
- Under Attributes, click the Partitions section to expand it.
- Set the Enable Partitions toggle to "On."
- Click +.
- In the Create Partition dialog:
- From the Elements dropdown menu, select an element containing the field to partition over.
- From the Fields dropdown menu, select the field to partition over. (The Fields dropdown menu cannot be opened until a selection is made from Elements.)
- Click the Split Array toggle to activate or deactivate array splitting. If set to "On," a unique partition is created for each element in the input array.
- Set the Partition Over Window toggle to "On" to allow treating windows as their own discrete entities (by granting each window a unique ID within Cogynt).
- Click Create to create the partition, or click Cancel to discard it.
The Partition Over Window toggle only appears if windowing is enabled. For more information, see Setting Windowing.
Editing Partitions
Existing partitions can be modified as needed.
To edit a partition:
- In the diagramming area, click an event pattern that contains a partition.
- In the details panel, click the Contents tab if it is not already selected.
- Under Attributes, click the Partitions section to expand it.
- Toggle Enable Partitions to "On" if it is not already.
- Click the pencil (✎) icon.
- Edit the partition details as needed. For more information about the partition details, see Steps 6 and 7 of Creating Partitions.
The Split Array toggle may be adjusted without having to click the pencil icon. For more information about splitting arrays, see Step 6 of Creating Partitions.
Deleting Partitions
Partitions that are no longer necessary can be removed.
To delete a partition:
- In the diagramming area, click an event pattern that contains a partition.
- In the details panel, click the Contents tab if it is not already selected.
- Under Attributes, click the Partitions section to expand it.
- Click the trash can (🗑) icon.
Setting Windowing
"Windowing" is the process of splitting a stream of data into portions of finite size, which can then be subjected to computations. Windowing separates the data from an input stream into discrete sections, making it possible to process and calculate data over time. For more information, refer to Windows in the official Apache Flink documentation.
To add windowing to an event pattern:
- In the diagramming area, click an event pattern to set windowing for.
- In the details panel, click the Contents tab if it is not already selected.
- Under Attributes, click the Windowing section to expand it.
- From the Window Type dropdown menu, select the desired window type ("Sliding" or "Tumbling"). For more information about these windowing types, refer to Tumbling Windows and Sliding Windows in the official Apache Flink documentation.
- From the Input Event Type dropdown menu, select the event type to use as the input.
- From the Referenced Timestamp dropdown menu, select the timestamp for the window to use as its referencing timeframe.
- If the Referenced Timestamp selection is anything other than "Kafka Ingestion Time", the Lateness field appears. In the Lateness field, specify the length and unit of time that the system should continue accepting and processing events from a window after it has closed.
- In the Window Length field, specify the minimum length of time that the window should span.
- In the Slide Length field, specify the length of time for each sliding window. (Note: This field appears only if Window Type is set to "Sliding".)
- From the Unit Type dropdown menu to the right of the Minimum Length field, specify the unit of time for the Minimum Length value.
- In the Timeout field, specify how long the system should wait before closing a window if no new input data is being received. (Note: The Timeout value should not exceed the Minimum Length value.)
- From the Unit Type dropdown menu to the right of the Timeout field, specify the unit of time for the Timeout value.
- Click outside of the details menu to save the changes.