Value Expression Examples
For these examples, we'll start with an empty Pipeline, and build it up. There is a sample file of Palo Alto firewall log data that we'll be using for these examples.
- If you still have the
Capture Sample Data
modal open, clickCancel
to close it. - Make sure
Processing / Pipelines
is selected in Stream's top nav. If necessary, drag the pane and column dividers to the right, so that you can see Pipeline names in the left pane. - Click the Pipeline named
value_starter
. - In the right
Sample Data
pane, find thefirewall_sample.log
sample file, and click theSimple
preview link to its right. - In the left pane, click the
Add Function
button, and search for and select theEval
function (or select it from the drop-down'sStandard
section).
At this point, the Stream screen should look something like this:
...and we're ready to start.
- In the
Eval
Function'sEvaluate Fields
section, click+ Add Field
. In the resulting table, enterdomain
in theName
field, and paste following expression into theValue Expression
field:(src_hostname || dest_hostname).substr((src_hostname||dest_hostname).indexOf('.')+1)
- Click
Save
- In the right
Preview Simple
pane, click theOUT
button near the top. This will show you the results of the Pipeline changes.
This expression is similar to the domain example on the previous page, but it will base it off of the src_hostname
field if that exists, or else off the dest_hostname
field if src_hostname
does not exist. If you look at the data on the right, you'll see the new domain field highlighted in green, and it will contain either the src_hostname
or the dest_hostname
field's value without the hostname.
Now, let's use the sample data's generated_time
field to create a new field that contains the UNIX-style timestamp version of that field.
- In the
Eval
Function'sEvaluate Fields
section, click+ Add Field
to add a second row to the table. - Enter
generated_epochtime
in the new row'sName
field. - Enter the following expression in the new row's
Value Expression
field:Date.parse(generated_time).toString()
- Click
Save
.
You should now see a new field in the output pane, called generated_epochtime
, which contains the number of milliseconds since the epoch (January 1, 1970, 1200am UTC).