Provides the number of elements in an array.

ParameterTypeRequiredDefault ValueDescription
array[a]stringrequired   Name of the array. For example, incidents[].
asstringoptional[b] _length Name of field that contains the output length.

[a] The parameter name array can be omitted.

[b] Optional parameters use their default value unless explicitly set.

Hide omitted argument names for this function

Show omitted argument names for this function

Given an event with an array field like animals[]:

animals[0]animals[1]animals[2]
horseduckbunny

and the following query:

logscale
array:length("animals[]")

The result is the number of elements found in the animals[] array field (horse, duck and bunny ) for that event:

_length
3

Only array elements in sequential order are counted — if there is a gap in the array, the function assumes it is the end of the array.

For example, given the event:

animals[0]animals[1]animals[3]
horseduckbunny

The query counts the first two elements only, thus it will output:

_length: 2

If applied to non-array input fields, the function returns 0.

Event:

Raw Events
#kind: logs

Query:

logscale Syntax
array:length("#kind")

Output:

_length: 0

Click + next to an example below to get the full details.

Count Array Elements - Example 1

Count Array Elements - Example 2