Functions
Use these functions in the Advanced Search interface to perform relatively complex data transformations. The Logs Query Builder does not natively support these functions.
formatDate
Returns a date string given a date, format, and timezone (default UTC).
- Syntax
-
| formatDate(<dateMilliseconds>) as <alias> | formatDate(<dateMilliseconds>, <formatString>) as <alias> | formatDate(<dateMilliseconds>, <formatString>, <timezoneString>) as <alias>
- Examples
-
The following example returns K with a value of
2024-11-06T20:33:37Z
.| formatDate(1730925217838) as K
The following example returns K with a value of
11-06-2024
.| formatDate(1730925217838, "01-02-2006") as K
The following example returns K with a value of
2024-11-06 12:33:37
.| formatDate(1730925217838, "2006-01-02 15:04:05", "America/Los_Angeles") as K
hash
Hashes data into a string value using the specified hash algorithm. Supported hash algorithms are MD5, SHA1, SHA2, and MurmurHash3.
- Syntax
-
| hash(<field>) as <alias> | hash(<field>, <hashAlgorithm>) as <alias> where <hashAlgorithm> is either md5(default), sha1, sha2_256, or murmur3_128
- Examples
-
The following example returns K with a value of
5eb63bbbe01eeed093cb22bb8f5acdc3
.| hash("hello world") as K
The following example returns K with a value of
2aae6c35c94fcfb415dbe95f408b9ce91ee846ed
.| hash("hello world", "sha1") as K
in
Checks if a field is in a set of string or number values.
- Syntax
-
where
-
| where <field> in (<value_1>[, <value_2>, <value_3>, …])
if
-
| if(<field> in (<value_1>[, <value_2>, <value_3>, …]), <value_if_true>, <value_if_false>) as <field>
- Examples
-
where
-
| source="pinot-server" | parse "[*]" as class | where class in ("ServerQueryLogger", "AppInfoParser")
if
-
| source="pinot-server" | parse "[*]" as class | if (class in ("ServerQueryLogger", "AppInfoParser"), "true class", "false class") as myClass
luhn
Validates credit card numbers in a string value using Luhn’s algorithm. The operator removes all non-numeric values and checks if the resulting string is a valid credit card number.
matches
Matches strings using the RE2-compliant regex format.
- Syntax
-
where
-
| where <string expression> matches "<regex>"
if
-
| if(<field> matches <regex_pattern>, <value_if_true>, <value_if_false>) as <field>
- Examples
-
where
-
| source="pinot-server" | parse "[*]" as class | where class matches "Server.*"
if
-
| source="pinot-server" | parse "[*]" as class | if (class matches "Server.*", "match found", "match not found") as myClass
replace
Replaces all occurrences of a specified string with another string. The specified string can be a literal or regex.
- Syntax
-
| replace(<sourceString>, <searchString>, <replaceString>) as <alias> | replace(<sourceString>, <regexString>, <replaceString>) as <alias>
- Examples
-
The following example returns K with a value of
hello gopher
.| replace("hello world", "world", "gopher") as K
The following example returns K with a value of
"http://kloudfuse.com/products//logs"
.| replace("http://kloudfuse.com/products/12345678/logs", "[0-9]{5,}", "") as K
substring
Extract a part of a given string and start/end offsets. If end offset is not provided, the substring is taken until the end of the source string.
urlDecode
Returns an unescaped url string.
- Syntax
-
| urlDecode(<urlString>) as <alias>
- Example
-
The following example returns K with a value of
http://example-server123.org/api/v1/data.php?auth=AbCdEfGhIjKlMnOpQrStUvWxYz123456&
.| urlDecode("http%3A%2F%2Fexample-server123.org%2Fapi%2Fv1%2Fdata.php%3Fauth%3DAbCdEfGhIjKlMnOpQrStUvWxYz123456%26") as K
urlEncode
Encodes url into ASCII character set.
- Syntax
-
| urlDecode(<urlString>) as <alias>
- Example
-
The following example returns
K
with a value ofhttp%3A%2F%2Fexample-server123.org%2Fapi%2Fv1%2Fdata.php%3Fauth%3DAbCdEfGhIjKlMnOpQrStUvWxYz123456%26
.| urlDecode("http://example-server123.org/api/v1/data.php?auth=AbCdEfGhIjKlMnOpQrStUvWxYz123456&") as K.