arrayfilter
Learn more about the Cortex Query Language arrayfilter() function.
Syntax
arrayfilter(<array>, <condition>)arrayfilter(<array>, "@element"<operator>"<array element>")Description
The arrayfilter() function returns a new array with the elements which meet the given condition. The function does this by filtering the results of an array in one of the following ways:
Returns the results when a certain condition is applied to the array.
Returns the results when a particular array is set to a specified array element.
Though it's possible to define the arrayfilter() function with any condition, the examples below focus on conditions using the @element that are based on the current element being tested.
Basic Example
When the dfe_labels array is not empty, use the alter stage to assign a value to a field called x that returns the value of the arrayfilter function. The arrayfilter function filters the dfe_labels array for the array element set to network.
dataset = xdr_data
| filter dfe_labels != null
| alter x = arrayfilter(dfe_labels , "@element" = "network")
| fields x, dfe_labels
| limit 100 Advanced Example
This queries below illustrate how to check whether any IPs are included or not included in the blocked list called CIDRS. The Query Results tables are also included to help explain what happens as the arrayfilter() function is slightly modified.
Last updated
Was this helpful?
