mvexpand
Turn an array field into one row per element, so you can filter, count or group on each value.
Use mvexpand to turn an array field into one row per element so you can filter, count, or group individual values. nano copies the other fields onto each new row.
Syntax
... | mvexpand <field> [limit=<n>]| Argument | Default | Description |
|---|---|---|
field | An array field, for example resources.uid or answers.rdata. | |
limit | 100000 | Maximum number of rows the expansion produces. |
How it works
- An event whose array has three elements becomes three rows. In each row,
<field>holds a single element. - An event whose array is empty produces no rows.
- Many OCSF fields are arrays. Common ones:
resources.uid,resources.name,observables.value,enrichments.value,enrichments.name,answers.rdata,email.to,file.hashes.value,vulnerabilities.cve.uid,http_request.url.categories. See the OCSF field reference.
Examples
Which AWS resources are touched most:
metadata.log_source=aws_cloudtrail | mvexpand resources.uid | stats count by resources.uid | sort -count | head 20Every address a DNS name resolved to:
class_uid=4003 | mvexpand answers.rdata | table time, device.hostname, query.hostname, answers.rdataWhich enrichment types fire on proxy traffic:
metadata.log_source=conduit_proxy | mvexpand enrichments.name | stats count by enrichments.nameRecipients of mail with a given subject, one row each:
class_uid=4009 email.subject="*invoice*" | mvexpand email.to | stats count by email.toNotes
- To test whether an array contains a value, you don't need
mvexpand:resources.uid="arn:aws:s3:::acme-prod-data"matches any element, and thehas()andmvfind()functions work on arrays. See Functions. - Filter before
mvexpand. Expanding first multiplies the rows every later command processes.