CIDR Lookup
Before we can configure the Lookup table, we need to extract the correct fields.
Parse the Events
In our previous challenge, we used the Regex Extract Function. But, because our new data follows a standard structure – in this case, CSV – we can use one of Cribl Stream's most powerful Functions: Parser
.
- With
Manage
active in Stream's top nav, click through toProcessing > Pipelines
. - If necessary, refresh the right pane by clicking
Sample Data
, then clickingSimple
next to the newnetflow_sample.csv
sample file. - Click the
Add Pipeline
button, then selectCreate Pipeline
. - In the new Pipeline's
ID
field, entercidr_lookup
. - Click
Save
. - Click
Add Functionon
and selectStandard
>Parser
. - Make sure the new Function's
Type
is set toCSV
.` - In the
List of Fields
, paste:StartTime,Dur,Proto,SrcAddr,Sport,Dir,DstAddr,Dport,State,sTos,dTos,TotPkts,TotBytes,SrcBytes,Label
- Your interface should now look like this (click to enlarge):
- Click
Save
.
The Parser
Function has split each event based on the CSV
type. To the resulting fields, it has then applied the field names you pasted in.
Create the Lookup Table
Now we're ready to create the Lookup table.
-
Select the
Processing
submenu in the top nav and clickKnowledge
.Note: Depending on the size of your window, the top nav will consolidate items that won't fit in a pulldown represented by an ellipsis (
...
) - if so, click on the ellipsis and then selectProcessing
and click onKnowledge
. -
If
Lookups
is not already selected in the left sidebar, click to select it. -
At the upper right, click
Add Lookup File
, then selectCreate with Text Editor
. -
Copy this text to the clipboard:
cidr,team
192.168.0.0/26,TeamA
192.168.0.64/26,TeamB
192.168.0.128/26,TeamC
192.168.0.192/26,TeamDThis Lookup table lists the four subnets and each subnet's associated team.
-
Paste the clipboard contents into large text field.
-
Type or paste
cidr_lookup.csv
into theFilename
field. Your interface should now look like this (click to enlarge): -
Click
Save
.
Configure the Lookup
Now, we are ready to configure the Lookup Function.
- Select the
Processing
submenu in Stream's top nav and clickPipelines
. - Choose the
cidr_lookup
Pipeline from the list of Pipelines on the left. - As before, in the right pane, click
Simple
next to thenetflow_sample.csv
sample. - To add the Lookup Function to the Pipeline, click
Add Functionon
, thenStandard
, thenLookup
. - Configure the Function to match this screenshot (click to enlarge):
- Click
Save
. - In the right Preview pane, toggle between
IN
andOUT
. When selectingOUT
, you should see the lookup values added to each event.
Send to Correct Index
Now we can use the value of the new team
field to send the data to the correct index. We'll use the same Eval
method we used in the last scenario.
- Make sure Stream's left pane still displays the
cidr_lookup
Pipeline. - In the right pane, make sure the
Preview Simple
tab still has focus, displaying events from yournetflow_sample.csv
sample. - To add the
Eval
Function, clickAdd Functionon
, thenStandard
, thenEval
. - Scroll down and click into your new
Eval
Function. - Configure the Function to match this screenshot (click to enlarge):
- Click
Save
. - In the right Preview pane, toggle between
IN
andOUT
. When selectingOUT
, you should see the new index values added to each event.
Note that we're setting the index value to team_src
. Since team_src
is not in quotes, it is not a literal – it refers to the value of the team_src
field for each event. (If team_src
had single quotes around it, like 'team_src'
, it would set each index value to the literal string 'team_src'
.)
Drop Non-Team Events
To complete this scenario, our customer wanted to filter out events that were not sent by any of their teams. For this, we used the Drop
Function to filter out events without the team_src
field.
- Make sure Stream's left pane still displays the
cidr_lookup
Pipeline. - As before, in the right pane, make sure the
Preview Simple
tab still has focus, displaying events from yournetflow_sample.csv
sample. - To add the
Drop
Function, clickAdd Functionon
, thenStandard
, thenDrop
. - Scroll down and click into your new
Drop
Function'sFilter
field. - As shown below (click to enlarge), replace the
Filter
field's defaulttrue
value with:!team_src
- Click
Save
.
Note that we've used the simple JavaScript filter !team_src
to filter out events that do not contain a team_src
field, meaning that these events were not sent by one of the four enumerated teams.