length
length
📝 StringReturn the number of characters in a string
length(string) → number number The count of characters in the string; null if input is null
The length function returns the number of characters in the input string.
Parameters
Section titled “Parameters”string— The input string to measure
Edge Cases
Section titled “Edge Cases”- If
stringisnull, returnsnull - Empty string
""has length0 - Spaces are counted:
length("hello world")returns11 - Counts Unicode characters correctly
Examples
Section titled “Examples”| where length(message) > 100
Matches records where message is longer than 100 characters.
| eval log_size_category = if(length(raw_log) > 10000, "large", "small")
Categorizes logs by size.
| stats avg(length(message)) by level
Calculates average message length by log level.
Used In
Section titled “Used In”eval— to create or transform numeric fields from strings