Understand Eval Functions

Eval allows you to define and name an expression that is returned in the search. To build an eval expression, you can use the following functions:

For more information about other operators, functions, and syntax requirements, see eval.

Comparison and Conditional Functions

coalesce(X, [Y, Z, N, ...])

Example

... | eval username = coalesce (Source Username, Destination Username)
Returns: Username

nullif(X,Y)

Example

... | eval newField = nullif(2, 3)
Returns: 2
... | eval newField = nullif(2, 2)
Returns: null

Cryptographic Function

md5(X)

Example

... | eval usermd5 = md5 (Destination Username)
Returns: 202cb962ac59075b964b07152d234b70

Informational Function

isnull(X)

Example

... | eval newField = isnull(2)
Returns: false

Statistical Functions

greatest(X,Y[,Z,N, ...])

Examples

... | eval newField = greatest(7, 5, 9)
Returns: 9
... | eval newField = greatest('sit', 'site', 'sight')
Returns: site
... | eval newField = greatest(bytesIn, 100)
Returns: 100, when bytesIn is less than 100

least(X,Y[,Z,N, ...])

Examples

.. | eval newField = least(bytesIn, bytesOut)
Returns: 5
... | eval newField = least('sit', 'site', 'sight')
Returns: sight
... | eval newField = least(bytesIn, 100)
Returns: 100, when bytesIn is greater than 100

randomint(X)

Example

... | eval newField = randomint(10)
Returns: a random number between 0 and 9

Text Functions

length(X)

Examples

... | eval n=length(field)
Returns: the length of (field). If the field is 256 characters long, it returns n=256.
... | eval n=length(“abc”)
Returns: n=3 (abc is a literal string, surrounded by double quotes)

lower(X)

Example

... | eval name=lower("USERNAME" )
... | eval name=tolower("USERNAME" )
Returns: the value of the field username in lowercase. If the username field contains FRED BROWN, it returns name=fredbrown.

substr(X,Y,Z)

Examples

...| eval n=substr("ArcSight", 5, 6)
Returns: “g”
...| eval n=substr("ArcSight", 2, 6)
Returns: “cSig”
...| eval n=substr("ArcSight", 0, 3)
Returns: “Arc”

trim(X)

ltrim(X)

rtrim(X)

Examples

For the sake of these examples, assume that X is a literal string and _ represents any number of space characters.

... | eval trimmed=ltrim(“_string_”)
Returns: trimmed=“string_”
... | eval trimmed=rtrim(“_string_”)
Returns: trimmed=“_string”
... | eval trimmed=trim(“_string_”)
Returns: “string”

upper(X)

Example

... | eval name=upper(“username”)
... | eval name=toupper(“username”)
Returns: the value of the field username in uppercase. If username contains fred brown, it returns name=FRED BROWN.