rename
Give a field a new name that later commands can use.
Use rename to give a field a new name for later commands in your pipeline.
Syntax
... | rename <field> as <new_name> [, <field> as <new_name> ...]| Argument | Description |
|---|---|
field | The field to rename: an OCSF path, or a field computed earlier (eval, rex, stats output). Quote names with spaces. |
new_name | The new name. Quote it if it contains spaces ("Source IP"). |
How it works
- Later commands can use the new name in
where,stats … by,sort,tableand so on. - The original field stays available under its old name as well. Use table or fields to choose which one appears in the output.
- Renaming several fields in one command is the same as chaining several
renamecommands. - Renaming onto an existing field replaces its value. For example,
rename actor.user.name as user.namereplaces the existinguser.namevalue withactor.user.name.
Examples
Short names for a source/destination pivot:
class_uid=4001 | rename src_endpoint.ip as client, dst_endpoint.ip as server | stats count by client, serverRename an account field, then filter and group on the new name:
class_uid=3002 status_id=2 | rename user.name as account | where account!="" | stats count by account | sort -countReport-friendly names that survive into the final table:
class_uid=4002 | rename http_request.url.hostname as "Site", http_response.code as "Status" | stats count by "Site", "Status"Rename an aggregate column:
class_uid=1007 | stats dc(device.hostname) as hosts by process.name | rename hosts as host_count | sort -host_countNotes
renamealso runs after a nano-side stage (lookup,prevalence,inputlookup,resolve_identity,ai,lateral).table <field> as <alias>selects and renames an output column. Userenamewhen you want to keep the other fields available.