Skip to main content
Use the len function in APL (Axiom Processing Language) to determine the length of a string or the number of elements in an array. This function is useful when you want to filter, sort, or analyze data based on the size of a value—whether that’s the number of characters in a request URL or the number of cities associated with a user. Use len when you need to:
  • Measure string lengths (for example, long request URIs).
  • Count elements in dynamic arrays (such as tags or multi-value fields).
  • Create conditional expressions based on the length of values.

For users of other query languages

If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.
In Splunk SPL, you often use the len function within eval or where expressions to determine string length or array size. In APL, len works similarly, but is used as a standalone scalar function.
In ANSI SQL, you use LENGTH() for strings and CARDINALITY() for arrays. In APL, len handles both cases—string and array—depending on the input type.

Usage

Syntax

Parameters

Returns

  • If value is a string, returns the number of characters.
  • If value is an array, returns the number of elements.
  • Returns null if the input is null.

Use case examples

Use len to find requests with long URIs, which might indicate poorly designed endpoints or potential abuse.Query
Run in PlaygroundOutputThe query filters logs for URIs longer than 100 characters and displays their lengths.
  • array_length: Returns the number of elements in an array. Use this when working specifically with arrays.
  • array_slice: Returns a subarray like array_extract, but supports negative indexing.
  • array_concat: Joins arrays end-to-end. Use before or after slicing arrays with array_extract.