On this page
mvexpand command
Split a field holding several values into one row per value, such as the list a values() aggregation returns.
Turns a field that holds several values into one row per value. Every other column is copied onto each new row.
The usual partner is a values() aggregation, which lists a group's distinct values in one column. Expanding that column gives each value a row of its own, which you can then filter, sort or count.
Over events, the field's text is split on a separator, a comma unless you name another one. Spaces around each value are trimmed and empty pieces are skipped.
Syntax
| mvexpand [limit=<count>] [delim="<separator>"] <field>Square brackets mark an optional part, and angle brackets a value you supply.
Arguments
| Argument | Required | Description |
|---|---|---|
limit=<count> | Optional | Expand at most this many values from each row. Defaults to every value. |
delim="<separator>" | Optional | The text between values in a field that is not a values() column. Defaults to a comma. A values() column is always expanded value by value, so a value that contains a comma stays whole. |
<field> | Required | The field or column to expand. One per stage. Add a second mvexpand to expand another field. |
Usage
- A row with no value in the field is kept once, with the field empty.
- Expanding events before a stats counts one row per value. stats count() after mvexpand counts values, not events.
- Two mvexpand stages over different fields give every combination of their values.
- mvexpand cannot follow dedup. Move it in front of the dedup.
- A column added by lookup cannot be expanded, because lookup runs after the search.
Examples
1. One row for each month a service was billed
service=aws-billing | stats values(cost_month) AS month by app | mvexpand monthvalues() lists the months for each app in one cell, and mvexpand gives each app and month its own row.
2. Count events by each of their tags
| mvexpand tags | stats count() by tagsAn event tagged "checkout, mobile" is counted once under each tag.
3. Split a semicolon separated list
| mvexpand delim=";" recipients | fields timestamp, recipientsOne row per recipient of each event.
4. Only the first three values
| stats values(host) AS host by service | mvexpand limit=3 hostAt most three rows for each service, taking the hosts in sorted order.