rename command to rename one or more fields. This command is useful for giving fields more meaningful names, such as "Product ID" instead of "pid". If you want to rename fields with similar names, you can use a wildcard character.
See the Usage section.
rename <wc-field> AS <wc-field>...
- Syntax: <string>
- Description: The name of a field and the name to replace it. Field names with spaces must be enclosed in quotation marks. You can use the asterisk ( * ) as a wildcard to specify a list of fields with similar names. For example, if you want to specify all fields that start with "value", you can use a wildcard such as
rename command is a distributable streaming command. See Command types.
Rename with a phrase
Use quotation marks when you rename a field with a phrase.
... | rename SESSIONID AS "The session ID"
Rename multiple, similarly named fields
Use wildcards to rename multiple fields.
... | rename *ip AS *IPaddress
If both the source and destination fields are wildcard expressions with the same number of wildcards, the renaming will carry over the wildcarded portions to the destination expression. See Examples.
You cannot rename one field with multiple names
You cannot rename one field with multiple names. For example if you have field A, you cannot specify
| rename A as B, A as C. This rule also applies to other commands where you can rename fields, such as the
The following example is not valid.
... | stats first(host) AS site, first(host) AS report
You cannot merge multiple fields into one field
You cannot use the
rename command to merge multiple fields into one field because null, or non-present, fields are brought along with the values.
For example, if you have events with either
... | rename pid AS product_id would not merge the
pid values into the
product_id field. It overwrites
product_id with Null values where
pid does not exist for the event. See the eval command and coalesce() function.
Renaming a field that does not exist
Renaming a field can cause loss of data.
Suppose you rename fieldA to fieldB, but fieldA does not exist.
- If fieldB does not exist, nothing happens.
- If fieldB does exist, the result of the rename is that the data in fieldB is removed. The data in fieldB will contain null values.
Rename the "_ip" field to "IPAddress".
... | rename _ip AS IPAddress
Rename fields beginning with "foo" to begin with "bar".
... | rename foo* AS bar*
Rename the "count" field. Names with spaces must be enclosed in quotation marks.
... | rename count AS "Count of Events"
This documentation applies to the following versions of Splunk Cloud Platform™: 8.1.2103, 8.2.2106, 8.2.2107, 8.2.2105, 8.2.2109, 8.2.2111, 8.2.2112, 8.2.2201 (latest FedRAMP release), 8.2.2202, 8.2.2203