This function removes duplicate values from an array. The ordering of the first occurrence of each unique element is preserved.
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
array
can be omitted; the following forms of this function are equivalent:logscale Syntaxarray:dedup("foo[]")
and:
logscale Syntaxarray:dedup(array="foo[]")
These examples show basic structure only.
For instance, given a rawstring with array a[]:
{ "a":["horse", "fish", "horse", "cow", "cow"] } |
Specify the name of the array field from which to remove duplicates:
parseJson()
| array:dedup("a[]")
The duplicate item will be removed:
a[0] | a[1] | a[2] |
---|---|---|
horse | fish | cow |
array:dedup()
Examples
Click
next to an example below to get the full details.Deduplicate Values in Array
Remove duplicate values in an array using
array:dedup()
Query
parseJson()
| array:dedup("emails[]")
Introduction
In this example, the function removes duplicates in the array emails[].
Example incoming data might look like this:
{"emails": ["john@mail.com", "admin@mail.com", "jane@mail.com", "admin@mail.com"]} |
Step-by-Step
Starting with the source repository events.
- logscale
parseJson()
Parses the incoming data to identify JSON values and converts them into a usable field.
- logscale
| array:dedup("emails[]")
Removes duplicate values in the array emails[].
Event Result set.
Summary and Results
The query is used to remove duplicate values in an array.
Sample output from the incoming example data:
emails[0] | emails[1] | emails[2] |
---|---|---|
john@mail.com | admin@mail.com | jane@mail.com |