Skip to Content

Analyze function reference

These are the functions an Analyze expression can call. Log Explorer suggests the same set from the expression box as you type.

An argument’s type says what you may pass, not what the engine derives. NUMBER covers every numeric type, because an attribute read with @ has no declared type and is read as a number on demand — see attribute values. An argument in square brackets may be omitted, and a trailing means the argument may be repeated.

Analyze is not the SQL transform. A SQL transform runs inside a pipeline on Flink SQL and supports a different function library, listed in its own reference. A function on that page may not exist here, and the functions below are not all available there.

Aggregate

FunctionArgumentsDescriptionExample
ANY_VALUEvalue: ANYReturn an arbitrary value from each group.
ANY_VALUE(@status)
Returns one arbitrary value from the group, keeping the attribute as it was stored.
APPROX_COUNT_DISTINCTvalue: ANY, …Estimate the number of distinct values.
APPROX_COUNT_DISTINCT(message)
Estimates how many distinct values the group holds.
APPROX_PERCENTILEvalue: NUMBER, fraction: NUMBEREstimate a percentile for numeric values. Returns a DOUBLE.
APPROX_PERCENTILE(severity, 0.5)
Estimates the median, and always returns a DOUBLE.
APPROX_PERCENTILE(@duration_ms, 0.95)
Estimates the 95th percentile of a variant attribute.
AVGvalue: NUMBERCalculate the average numeric value; attribute types are inferred from context.
AVG(severity)
Averages a numeric column across the group.
AVG(@duration_ms)
Reads a variant attribute as a number, giving NULL for any row where it does not hold one.
COUNT[value: ANY], …Count rows or distinct values.
COUNT(*)
Counts every row in the group.
COUNT(@duration_ms)
Counts only the rows where the attribute is present.
COVAR_POPy: NUMBER, x: NUMBERCalculate population covariance.
COVAR_POP(severity, severity)
Measures how two numeric columns vary together across the population.
COVAR_SAMPy: NUMBER, x: NUMBERCalculate sample covariance.
COVAR_SAMP(severity, severity)
Measures how two numeric columns vary together in the sample.
EVERYcondition: BOOLEANTest whether every value in a group is true.
EVERY(severity > 0)
Reports whether the condition held for every row in the group.
MAXvalue: ANYReturn the maximum value; attribute types are inferred from context.
MAX(severity)
Returns the largest value in the group.
MAX(@duration_ms)
Compares the attribute numerically, not as JSON text.
MINvalue: ANYReturn the minimum value; attribute types are inferred from context.
MIN(severity)
Returns the smallest value in the group.
MIN(@duration_ms)
Compares the attribute numerically, not as JSON text.
STDDEVvalue: NUMBERCalculate sample standard deviation.
STDDEV(severity)
Measures the sample standard deviation.
STDDEV_POPvalue: NUMBERCalculate population standard deviation.
STDDEV_POP(severity)
Measures the population standard deviation.
STDDEV_SAMPvalue: NUMBERCalculate sample standard deviation.
STDDEV_SAMP(severity)
Measures the sample standard deviation.
SUMvalue: NUMBERSum numeric values; attribute types are inferred from context.
SUM(severity)
Totals a numeric column across the group.
SUM(@duration_ms)
Reads a variant attribute as a number, giving NULL for any row where it does not hold one.
VARIANCEvalue: NUMBERCalculate statistical variance.
VARIANCE(severity)
Measures the sample variance.
VAR_POPvalue: NUMBERCalculate population variance.
VAR_POP(severity)
Measures the population variance.
VAR_SAMPvalue: NUMBERCalculate sample variance.
VAR_SAMP(severity)
Measures the sample variance.

Attributes and variants

FunctionArgumentsDescriptionExample
VARIANT_SOME_BETWEENattribute: ANY, lower: NUMBER, upper: NUMBER, lowerInclusive: BOOLEAN, upperInclusive: BOOLEANTest whether a Variant value is in a numeric range.
VARIANT_SOME_BETWEEN(@status, 400, 500, TRUE, TRUE)
Matches a numeric range, with each bound included or excluded explicitly.
VARIANT_SOME_EQattribute: ANY, value: ANYCompare a Variant value for equality.
VARIANT_SOME_EQ(@status, 404)
Matches when the attribute, or any element of it, equals the value.
VARIANT_SOME_EQ_ALLattribute: ANY, value: ANY, more: ANY, …Compare a Variant value against all candidates.
VARIANT_SOME_EQ_ALL(@status, 404, 500)
Matches when the attribute covers every one of the candidates.
VARIANT_SOME_EQ_INattribute: ANY, value: ANY, more: ANY, …Compare a Variant value against any candidate.
VARIANT_SOME_EQ_IN(@status, 404, 500)
Matches when the attribute equals any one of the candidates.
VARIANT_SOME_GEattribute: ANY, value: ANYCompare a Variant value as greater than or equal.
VARIANT_SOME_GE(@status, 400)
Matches when the attribute, or any element of it, is greater or equal.
VARIANT_SOME_GTattribute: ANY, value: ANYCompare a Variant value as greater than.
VARIANT_SOME_GT(@status, 400)
Matches when the attribute, or any element of it, is greater.
VARIANT_SOME_LEattribute: ANY, value: ANYCompare a Variant value as less than or equal.
VARIANT_SOME_LE(@status, 500)
Matches when the attribute, or any element of it, is smaller or equal.
VARIANT_SOME_LTattribute: ANY, value: ANYCompare a Variant value as less than.
VARIANT_SOME_LT(@status, 500)
Matches when the attribute, or any element of it, is smaller.
VARIANT_SOME_STRING_RANGEattribute: ANY, lower: TEXT, upper: TEXT, lowerInclusive: BOOLEAN, upperInclusive: BOOLEANTest whether a Variant value is in a text range.
VARIANT_SOME_STRING_RANGE(@status, 'a', 'z', TRUE, TRUE)
Matches a text range, with each bound included or excluded explicitly.

String

FunctionArgumentsDescriptionExample
CHARACTER_LENGTHtext: TEXTReturn the number of characters in text.
CHARACTER_LENGTH(message)
Counts the characters in a string, spelled out in full.
CHAR_LENGTHtext: TEXTReturn the number of characters in text.
CHAR_LENGTH(message)
Counts the characters in a string.
CONCATvalue: ANY, more: ANY, …Concatenate values as text.
CONCAT(message, 'x')
Joins two values into one string.
CONCAT(message, ':', severity)
Joins any number of values, converting each to text.
LOWERtext: TEXTConvert text to lower case.
LOWER(message)
Converts a string to lower case.
POSITIONkeyword syntax — see the exampleFind text within a string.
POSITION('a' IN message)
Returns the 1-based position of a substring, or 0 when it is absent.
REGEXP_CONTAINStext: TEXT, pattern: TEXTTest whether text matches a regular expression.
REGEXP_CONTAINS(message, 'a')
Reports whether a regular expression matches anywhere in the text.
REGEXP_EXTRACTtext: TEXT, pattern: TEXT, [group: NUMBER]Extract text captured by a regular expression.
REGEXP_EXTRACT(message, 'a')
Returns the text a regular expression matched, or NULL when it did not match.
REGEXP_EXTRACT(message, '(a)(b)', 2)
Returns a numbered capture group rather than the whole match.
REPLACEtext: TEXT, search: TEXT, replacement: TEXTReplace matching text in a string.
REPLACE(message, 'a', 'b')
Replaces every occurrence of one string with another.
SEVERITY_TEXTseverity: NUMBERConvert an OTel severity number to its name.
SEVERITY_TEXT(severity)
Names the severity bucket: TRACE, DEBUG, INFO, WARN, ERROR or FATAL.
SUBSTRINGkeyword syntax — see the exampleExtract part of a string.
SUBSTRING(message FROM 1 FOR 3)
Takes a fixed number of characters from a starting position.
SUBSTRING(message FROM 5)
Takes everything from the starting position to the end.
TRIMtext: TEXTRemove leading or trailing characters.
TRIM(message)
Removes leading and trailing whitespace.
UPPERtext: TEXTConvert text to upper case.
UPPER(message)
Converts a string to upper case.

Date and time

FunctionArgumentsDescriptionExample
CONVERT_TIMEZONEsource: TEXT, target: TEXT, timestamp: TIMESTAMPConvert a UTC timestamp to another time zone. Source must be UTC.
CONVERT_TIMEZONE('UTC', 'America/Chicago', event_timestamp)
Converts a stored timestamp into another time zone; the source must be 'UTC', which is how Grepr stores timestamps.
CURRENT_DATEno argumentsReturn the current date.
CURRENT_DATE
Returns the current date, in UTC.
CURRENT_TIMESTAMPsee the exampleReturn the current timestamp.
CURRENT_TIMESTAMP
Returns the current timestamp, in UTC.
DATE_FORMATformat: TEXT, timestamp: TIMESTAMP, [timezone: TEXT]Format a date or timestamp as text.
DATE_FORMAT('yyyy-MM-dd', event_timestamp)
Renders a timestamp as text in a given pattern.
DATE_FORMAT('yyyy-MM-dd', event_timestamp, 'America/Chicago')
Renders the timestamp in a given time zone rather than UTC.
DAYOFMONTHtimestamp: TIMESTAMPExtract the day of month from a timestamp.
DAYOFMONTH(event_timestamp)
Returns the day of the month.
DAYOFWEEKtimestamp: TIMESTAMPExtract the day of week from a timestamp.
DAYOFWEEK(event_timestamp)
Returns the day of the week.
DAYOFYEARtimestamp: TIMESTAMPExtract the day of year from a timestamp.
DAYOFYEAR(event_timestamp)
Returns the day of the year.
EXTRACTkeyword syntax — see the exampleExtract a date or time field.
EXTRACT(HOUR FROM event_timestamp)
Pulls one calendar field out of a timestamp.
HOURtimestamp: TIMESTAMPExtract the hour from a timestamp.
HOUR(event_timestamp)
Returns the hour, 0 to 23.
LAST_DAYtimestamp: TIMESTAMPReturn the last day of a calendar period.
LAST_DAY(event_timestamp)
Returns the last day of that month.
MINUTEtimestamp: TIMESTAMPExtract the minute from a timestamp.
MINUTE(event_timestamp)
Returns the minute, 0 to 59.
MONTHtimestamp: TIMESTAMPExtract the month from a timestamp.
MONTH(event_timestamp)
Returns the calendar month, 1 to 12.
QUARTERtimestamp: TIMESTAMPExtract the quarter from a timestamp.
QUARTER(event_timestamp)
Returns the calendar quarter, 1 to 4.
SECONDtimestamp: TIMESTAMPExtract the second from a timestamp.
SECOND(event_timestamp)
Returns the second, 0 to 59.
TIMESTAMPADDunit: TIME_UNIT, count: NUMBER, timestamp: TIMESTAMPAdd a time interval to a timestamp.
TIMESTAMPADD(HOUR, 1, event_timestamp)
Shifts a timestamp forward by a whole number of calendar units.
TIMESTAMPDIFFunit: TIME_UNIT, start: TIMESTAMP, end: TIMESTAMPMeasure the interval between timestamps.
TIMESTAMPDIFF(HOUR, event_timestamp, event_timestamp)
Counts whole calendar units between two timestamps.
WEEKtimestamp: TIMESTAMPExtract the week from a timestamp.
WEEK(event_timestamp)
Returns the week of the year.
YEARtimestamp: TIMESTAMPExtract the year from a timestamp.
YEAR(event_timestamp)
Returns the calendar year.

Numeric

FunctionArgumentsDescriptionExample
ABSvalue: NUMBERReturn the absolute numeric value.
ABS(severity)
Returns the magnitude of a number, without its sign.
ABS(@duration_ms)
Reads a variant attribute as a number, giving NULL for any row where it does not hold one.
ACOSvalue: NUMBERReturn the inverse cosine.
ACOS(severity)
Returns the arc cosine, in radians.
ASINvalue: NUMBERReturn the inverse sine.
ASIN(severity)
Returns the arc sine, in radians.
ATANvalue: NUMBERReturn the inverse tangent.
ATAN(severity)
Returns the arc tangent, in radians.
ATAN2y: NUMBER, x: NUMBERReturn the two-argument inverse tangent.
ATAN2(severity, severity)
Returns the angle to a point, using both coordinates to fix the quadrant.
CEILvalue: NUMBERRound a numeric value up.
CEIL(severity)
Rounds up to a whole number.
COSvalue: NUMBERReturn the cosine.
COS(severity)
Returns the cosine of an angle in radians.
COTvalue: NUMBERReturn the cotangent.
COT(severity)
Returns the cotangent of an angle in radians.
DEGREESradians: NUMBERConvert radians to degrees.
DEGREES(severity)
Converts radians to degrees.
EXPvalue: NUMBERReturn e raised to a power.
EXP(severity)
Raises e to the given power.
FLOORvalue: NUMBERRound a numeric value down.
FLOOR(severity)
Rounds down to a whole number.
FLOOR(event_timestamp TO HOUR)
Truncates a timestamp down to the start of a calendar unit.
LNvalue: NUMBERReturn the natural logarithm.
LN(severity)
Returns the natural logarithm.
LOGvalue: NUMBER, [base: NUMBER]Return a logarithm with the selected base.
LOG(severity)
Returns the natural logarithm when no base is given.
LOG(severity, 2)
Returns the logarithm in a given base.
LOG10value: NUMBERReturn the base-10 logarithm.
LOG10(severity)
Returns the base-10 logarithm.
MODdividend: NUMBER, divisor: NUMBERReturn the remainder after division.
MOD(severity, 2)
Returns the remainder of a division.
PIno argumentsReturn the mathematical constant pi.
PI()
Returns the constant pi.
POWERbase: NUMBER, exponent: NUMBERRaise a number to a power.
POWER(severity, 2)
Raises a number to a power.
RADIANSdegrees: NUMBERConvert degrees to radians.
RADIANS(severity)
Converts degrees to radians.
ROUNDvalue: NUMBER, [digits: NUMBER]Round a numeric value.
ROUND(severity)
Rounds to the nearest whole number.
ROUND(severity, 2)
Rounds to a given number of decimal places.
SIGNvalue: NUMBERReturn the sign of a numeric value.
SIGN(severity)
Returns -1, 0, or 1 according to the sign.
SINvalue: NUMBERReturn the sine.
SIN(severity)
Returns the sine of an angle in radians.
SQRTvalue: NUMBERReturn the square root of a number.
SQRT(severity)
Returns the square root.
TANvalue: NUMBERReturn the tangent.
TAN(severity)
Returns the tangent of an angle in radians.
TRUNCATEvalue: NUMBER, [digits: NUMBER]Truncate a numeric value.
TRUNCATE(severity)
Drops the fractional part, without rounding.
TRUNCATE(severity, 2)
Keeps a given number of decimal places, without rounding.

Conditional

FunctionArgumentsDescriptionExample
CASEkeyword syntax — see the exampleReturn a value based on ordered conditions.
CASE WHEN severity > 3 THEN 'high' ELSE 'low' END
Picks a result from the first condition that holds.
CASE WHEN severity > 4 THEN 'error' WHEN severity > 2 THEN 'warn' ELSE 'info' END
Tests conditions in order, so the first match wins.
COALESCEvalue: ANY, fallback: ANY, …Return the first non-null expression.
COALESCE(message, 'none')
Returns the first argument that is not NULL.
COALESCE(@duration_ms, severity, 0)
Falls through several candidates to a literal default.
NULLIFvalue: ANY, other: ANYReturn NULL when two expressions are equal.
NULLIF(message, 'none')
Returns NULL when the two arguments are equal, and the first otherwise.

Type conversion

FunctionArgumentsDescriptionExample
CASTkeyword syntax — see the exampleConvert an expression to a specific SQL type when type or precision control is needed.
CAST(severity AS VARCHAR)
Converts a value to a named SQL type.
CAST(@duration_ms AS BIGINT)
Forces an attribute to an exact type instead of the inferred one.
IS_NUMERICvalue: ANYTest whether an attribute is stored as a numeric type.
IS_NUMERIC(@status)
Reports whether an attribute was stored as a number.
TO_JSON_STRINGvalue: ANYSerialize a value as JSON text.
TO_JSON_STRING(@status)
Renders a value as JSON text.
TRY_CASTkeyword syntax — see the exampleConvert an expression, returning NULL when conversion fails.
TRY_CAST(message AS BIGINT)
Converts a value, giving NULL instead of failing when it will not convert.
TYPEOFvalue: ANYReturn the SQL type of an expression.
TYPEOF(@status)
Reports the SQL type an expression resolved to.

Arrays and maps

FunctionArgumentsDescriptionExample
ARRAY_CONTAINSarray: ARRAY, value: ANYTest whether an array contains a value.
ARRAY_CONTAINS(tags['service'], 'api')
Reports whether an indexed tag holds a given value.
ARRAY_CONTAINS_ALL_IGNORE_CASEarray: ARRAY, value: TEXT, more: TEXT, …Test whether all values occur in an array.
ARRAY_CONTAINS_ALL_IGNORE_CASE(tags['service'], 'api', 'web')
Reports whether every one of the given values occurs.
ARRAY_CONTAINS_ANY_IGNORE_CASEarray: ARRAY, value: TEXT, more: TEXT, …Test whether any value occurs in an array.
ARRAY_CONTAINS_ANY_IGNORE_CASE(tags['service'], 'api', 'web')
Reports whether at least one of the given values occurs.
ARRAY_CONTAINS_IGNORE_CASEarray: ARRAY, value: TEXTTest array membership without case sensitivity.
ARRAY_CONTAINS_IGNORE_CASE(tags['service'], 'api')
Reports tag membership without regard to case.
ARRAY_TO_STRINGarray: ARRAY, delimiter: TEXT, [nullValue: TEXT]Join array elements into a string.
ARRAY_TO_STRING(tags['service'], ',')
Joins the values of an indexed tag into one string.
ARRAY_TO_STRING(tags['service'], ',', 'none')
Substitutes a placeholder for null elements instead of skipping them.
CARDINALITYcollection: ANYReturn the number of elements in a collection.
CARDINALITY(tags)
Counts the entries in a map or array.
MAP_KEYSmap: MAPReturn the keys of a map.
MAP_KEYS(tags)
Returns the keys a map holds.
MAP_VALUESmap: MAPReturn the values of a map.
MAP_VALUES(tags)
Returns the values a map holds.
SORT_ARRAYarray: ARRAY, [ascending: BOOLEAN]Sort the elements of an array ascending; pass FALSE as the second argument for descending. The elements must be numbers, strings, binary or date-time values. Sorting a tag's values first makes the same combination of values group together.
SORT_ARRAY(tags['team'])
Sorts the team tag's values.
ARRAY_TO_STRING(SORT_ARRAY(tags['team']), ',')
Groups rows by the whole set of team values, in a stable order.

Bitwise

FunctionArgumentsDescriptionExample
BITANDleft: NUMBER, right: NUMBERApply a bitwise AND operation.
BITAND(severity, 1)
Combines two integers with a bitwise AND.
BITCOUNTvalue: NUMBERCount set bits in an integer.
BITCOUNT(severity)
Counts the bits set in an integer.
BITNOTvalue: NUMBERApply a bitwise NOT operation.
BITNOT(severity)
Inverts every bit of an integer.
BITORleft: NUMBER, right: NUMBERApply a bitwise OR operation.
BITOR(severity, 1)
Combines two integers with a bitwise OR.
BITXORleft: NUMBER, right: NUMBERApply a bitwise XOR operation.
BITXOR(severity, 1)
Combines two integers with a bitwise exclusive OR.
Last updated on