Home / Search/ Language Reference/Functions

Functions

A comprehensive list of all functions supported in Cribl Search, grouped by category.


Context Functions

Context functions return contextual information about your search.

NameDescription
createdTime()Time when the search was created, in seconds.
earliestTime()Beginning of the search’s time range, in seconds.
jobID()Unique search identifier.
latestTime()End of the search’s time range, in seconds.
query()Query string.
user()Username of the user who created the search.
displayUsername()Friendly display name (typically first + last name) of the user who created the search.

Cribl Functions

Cribl functions can be used together with the summarize, eventstats, and timestats operators to aggregate your data. We refer to those additional functions as Cribl functions, since they’re specific to Cribl Search.

NameDescription
findearliestReturns the earliest value of an expression across the group.
findearliestifReturns the earliest value of an expression across the group for which a predicate evalutes to true.
findfirstReturns the first observed value of an expression across the group.
findfirstifReturns the first observed value of an expression across the group for which a predicate evalutes to true.
findlastReturns the last observed value of an expression across the group.
findlastifReturns the last observed value of an expression across the group for which a predicate evalutes to true.
findlatestReturns the latest value of an expression across the group.
findlatestifReturns the latest value of an expression across the group for which a predicate evalutes to true.
listReturns the list of values of an expression across the group
medianReturns the middle value of an expression across the group.
medianifReturns the middle value of an expression across the group for which a predicate evalutes to true.
persecondReturns the per-second rate of an expression across the group
persecondifReturns the per-second rate of an expression across the group for which a predicate evalutes to true.
rateReturns the rate observed value of an expression across the group.
rateifReturns the rate observed value of an expression across the group for which a predicate evalutes to true.
sumsqReturns the sum of squares of an expression across the group.
sumsqifReturns the sum of squares of an expression across the group for which a predicate evalutes to true.
valuesReturns all of the distinct values of an expression across the group.

Scalar Functions

Scalar functions perform calculations, transformations, or conversions.

Binary Functions

NameDescription
binary_andReturns a result of the bitwise and operation between two values.
binary_notReturns a bitwise negation of the input value.
binary_orReturns a result of the bitwise or operation of the two values.
binary_shift_leftReturns binary shift left operation on a pair of numbers.
binary_shift_rightReturns binary shift right operation on a pair of numbers.
binary_xorReturns the bitwise xor operation of the two values.
from_binary_stringTakes a binary string and returns a number.
to_binary_stringTakes a number and returns a binary string.

Conditional Functions

NameDescription
caseEvaluates a list of predicates and returns the first result expression whose predicate is satisfied.
coalesceEvaluates a list of expressions and returns the first non-null (or non-empty for string) expression.
iif (iff)Evaluates the first argument (the predicate), and returns the value of either the second or third arguments, depending on whether the predicate evaluated to true (second) or false (third).
max_ofReturns the maximum value of several evaluated numeric expressions.
min_ofReturns the minimum value of several evaluated numeric expressions.

Conversion Functions

NameDescription
binRounds values down to an integer multiple of a given bin size.
bin_autoRounds values down to a fixed-size bin.
floorRounds values down to an integer multiple of a given floor size.
gettypeReturns the type of the input value.
toboolConverts the input to a bool value.
todouble (toreal, todecimal)Converts the input to a double (real, decimal) value.
toint (tolong)Converts the input to an int (long) value.
tostringConverts the input to a string value.

DateTime Functions

NameDescription
agoSubtracts the given timespan from the current UTC clock time.
datetime_addCalculates a new datetime from a specified datepart multiplied by a specified amount, added to a specified datetime.
datetime_diffCalculates the number of the specified periods between two datetime values.
datetime_partExtracts the requested date part as an integer value.
dayofmonthReturns the integer number representing the day number of the given month.
dayofweekReturns an integer between 0 and 6 representing the day of the week, beginning on Sunday.
dayofyearReturns the integer number representing the day number of the given year.
endofdayReturns the end of the day containing the date, shifted by an offset, if provided.
endofmonthReturns the end of the month containing the date, shifted by an offset, if provided.
endofweekReturns the end of the week containing the date, shifted by an offset, if provided.
endofyearReturns the end of the year containing the date, shifted by an offset, if provided.
format_datetimeFormats a datetime according to the provided format.
format_timespanFormats a timespan according to the provided format.
getmonth (monthofyear)Gets the month number (1–12) from a datetime.
getyear (yearofyear)Returns the year part of a datetime.
hourofdayReturns the integer number representing the hour number of the given date.
make_datetimeConverts the specified date and time into a datetime value (Unix time in seconds).
make_timespanConverts the specified time period into a datetime value (Unix time in seconds).
nowReturns the current UTC clock time as a datetime value (Unix time in seconds).
startofdayReturns the start of the day containing the date, shifted by an offset, if provided.
startofmonthReturns the start of the month containing the date, shifted by an offset, if provided.
startofweekReturns the start of the week containing the date, shifted by an offset, if provided.
startofyearReturns the start of the year containing the date, shifted by an offset, if provided.
strftime (format_time)Converts a datetime (date) object to a human-readable string.
strptime (parse_time)Converts a string to a datetime.
todatetimeConverts the input into a datetime value (Unix time in seconds).
totimespanConverts the input into a number of seconds.
unixtime_microseconds_todatetimeConverts the input into a datetime value (Unix time in seconds).
unixtime_milliseconds_todatetimeConverts the input into a datetime value (Unix time in seconds).
unixtime-nanoseconds_todatetimeConverts the input into a datetime value (Unix time in seconds).
unixtime_seconds_todatetimeConverts the input into a datetime value (Unix time in seconds).
week_of_yearReturns an integer representing the week number.

Dynamic Functions

Dynamic scalar functions allow you to manipulate objects by operating on dynamic values, including dynamic arrays and property bags.

NameDescription
bag_has_keyChecks whether a property bag contains a given key.
bag_keysLists all root keys of a property bag.
bag_mergeMerges multiple property bags, discarding duplicate keys.
bag_packCreates a property bag from an alternating list of keys and values.
bag_pack_columnsCreates a property bag from a list of columns.
bag_remove_keysRemoves key-value pairs from a property bag.
bag_set_keyAdds or overwrites a key-value pair in a property bag.
bag_zipCreates a property bag from two dynamic arrays.
make_bagCreates a property bag from multiple input bags.
make_bag_ifCreates a property bag from those input bags that meet the specified condition.
zipMerges dynamic arrays, grouping elements by index.

The following string functions support dynamic types as well:

FunctionUsage with dynamic data types
extractjson(`path,object`)Uses path to navigate into object.
parse_json(`source`)Turns a JSON string into a dynamic object.
range(`from,to,step`)Generates an array of values.

Hash Functions

NameDescription
hashReturns a hash value for the input value.
hash_combineCombines hash values of two or more hashes.
hash_manyReturns a combined hash value of multiple values.
hash_md5Returns an MD5 hash value for the input value.
hash_sha1Returns a SHA1 hash value for the input value.
hash_sha256Returns a SHA-256 hash value for the input value.
hash_xxhash64Returns a 64-bit hash value for the input value.

INET Functions

NameDescription
ipv4_compareCompares two IPv4 strings.
ipv4_is_in_rangeChecks if IPv4 string address is in IPv4-prefix notation range.
ipv4_is_in_any_rangeChecks whether IPv4 string address is in any of the specified IPv4 address ranges.
ipv4_is_matchMatches two IPv4 strings.
ipv4_is_privateChecks if IPv4 string address belongs to a set of private network IPs.
ipv4_netmask_suffixReturns the value of the IPv4 netmask suffix from IPv4 string address.
ipv6_compareCompares two IPv6 or IPv4 network address strings.
ipv6_is_matchMatches two IPv6 or IPv4 network address strings.
format_bytesConverts the input into a string that represents data size.
format_ipv4Parses input with a netmask and returns string representing IPv4 address.
format_ipv4_maskParses input with a netmask and returns string representing IPv4 address as CIDR notation.

Mathematical Functions

NameDescription
absCalculates the absolute value of the input.
acosCalculates the angle whose cosine is the specified number.
asinCalculates the angle whose sine is the specified number.
atanReturns the angle whose tangent is the specified number.
atan2Calculates the angle, in radians, between the positive x-axis and the ray from the origin to the point (y, x).
beta_cdfReturns the standard cumulative beta distribution function.
beta_invReturns the inverse of the beta cumulative probability beta density function.
beta_pdfReturns the probability density beta function.
ceilRounds up a numeric expression’s value to the nearest integer.
ceilingRounds up a numeric expression’s value to the nearest integer.
cosReturns the cosine function.
cotCalculates the trigonometric cotangent of the specified angle, in radians.
degreesConverts angle value in radians into value in degrees.
expCalculates the base-e exponential function of x.
exp2Calculates the base-2 exponential function of x.
exp10Calculates the base-10 exponential function of x.
gammaComputes gamma function.
isfiniteReturns whether input is a finite value.
isinfReturns whether input is an infinite value.
isnanReturns whether input is Not-a-Number (NaN) value.
logReturns the natural logarithm function.
log2Returns the (base-2) logarithm function.
log10Returns the common (base-10) logarithm function.
loggammaComputes log of absolute value of the loggamma function.
notReverses the value of its boolean argument.
piReturns the constant value of Pi.
powReturns a result of raising to power.
radiansConverts angle value in degrees into value in radians.
randReturns a random number.
rangeGenerates a dynamic array, holding a series of equally spaced values.
roundReturns the rounded source to the specified precision.
signReturns the sign of a numeric expression.
sinReturns the sine of a numeric expression.
sqrtReturns the square root function.
tanReturns the tangent function.

String Functions

NameDescription
base64_decode_toarrayDecodes a base64 string to an array of long values.
base64_decode_tostringDecodes a base64 string to a UTF-8 string.
base64_encode_fromarrayEncodes a base64 string from a bytes array.
base64_encode_tostringEncodes a string as base64 string.
countofCounts occurrences of a substring in a string.
extractGets a match for an RE2 regular expression from a source string.
extract_allGets all matches for an RE2 regular expression from a source string.
extract_jsonGets a specified element out of a JSON text using a path expression.
has_any_indexGets a match for an RE2 regular expression from a source string.
indexofReports the zero-based index of the first occurrence of a specified string within the input string.
isemptyReturns true if the argument is an empty string or is null.
isnotempty (notempty)Returns true if the argument isn’t an empty string, and it isn’t null.
isnotnull (notnull)Returns true if the argument is not null.
isnullIndicates whether the argument evaluates to a null value.
match_regexSearches a text string for a specific pattern defined by a regular expression.
parse_csvSplits a given string representing a single record of comma-separated values.
parse_ipv4Converts IPv4 string to long (signed 64-bit) number representation in big-endian order.
parse_ipv4_maskConverts the input string of IPv4 and netmask to a signed, 64-bit wide, long number representation in big-endian order.
parse_ipv6Converts IPv6 or IPv4 string to a canonical IPv6 string representation.
parse_ipv6_maskConverts IPv6/IPv4 string and netmask to a canonical IPv6 string representation.
parse_json (todynamic)Interprets a string as a JSON value and returns the value as dynamic.
parse_urlParses an absolute URL string and returns a dynamic object that contains URL parts.
parse_urlqueryReturns a dynamic object that contains the Query parameters.
parse_versionConverts the input string representation of version to a comparable decimal number.
replace_regexReplaces all RE2 regular expression matches with another string.
reverseReverses the order of the input string.
splitSplits a given string according to a given delimiter.
strcatConcatenates between 1 and 64 arguments.
strcat_delimConcatenates between 2 and 64 arguments, with a delimiter.
strcmpCompares two strings.
strlenReturns the length, in characters, of the input string.
strrepRepeats given string specified number of times.
substringExtracts a substring from a source string starting from some index to the end of the string.
tolowerConverts a string to lower case.
toupperConverts a string to upper case.
translateReplaces a set of characters with another set of characters in a given string.
trimRemoves all leading and trailing matches of the specified string or regular expression.
trim_endRemoves trailing match of the specified regular expression.
trim_startRemoves leading match of the specified regular expression.
url_decodeConverts encoded URL into a to regular URL representation.
url_encodeConverts characters of the input URL into a format that can be transmitted over the Internet.

Statistical Functions

NameDescription
avgCalculates the average across the group.
avgifCalculates the average across the group where a predicate evaluates to true.
countCounts events per summarization group.
countifCounts events based on a predicate.
dcountCalculates an estimate of the number of distinct values.
dcountifCalculates an estimate of the number of distinct values for those rows where a predicate evaluates to true.
maxFinds the maximum value across the group.
maxifFinds the maximum value for which a predicate evaluates to true.
minFinds the minimum value across the group.
minifFinds the minimum value which a predicate evaluates to true.
percentileReturns an estimate for the specified nearest-rank percentile of the population defined.
stdevCalculates the standard deviation of an expression across the group.
stdevifCalculates the standard deviation of an expression which a predicate evaluates to true.
stdevpCalculates the standard deviation of an expression across the group, considering the group as a population.
sumCalculates the sum of an expression across the group.
sumifCalculates the sum of an expression for which a predicate evaluates to true.
varianceCalculates the variance of an expression.
varianceifCalculates the variance of an expression for which a predicate evaluates to true.
variancepCalculates the variance of an expression across the group, considering the group as a population.

Window Functions

NameDescription
nextReturns the value of a specific field in a subsequent row.
prevReturns the value of a specific field in a previous row.
row_cumsumCalculates the cumulative sum for a specified field across all previous rows.
row_numberAssigns a unique row number to each row within the results.
row_rank_denseAssigns a unique numerical position (rank) to each row within the results
row_rank_minAssigns a minimal numerical position (rank) to each row within the results
row_window_sessionIdentifies the value at the beginning of each session for a specified field within the results.