Skip to content

length

length

📝 String

Return 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.

  • string — The input string to measure
  • If string is null, returns null
  • Empty string "" has length 0
  • Spaces are counted: length("hello world") returns 11
  • Counts Unicode characters correctly
| 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.

  • eval — to create or transform numeric fields from strings