This function renames one or more fields.

ParameterTypeRequiredDefault ValueDescription
asstringoptional[a]   The new name of the field; it is used when a single field name is given in field.
field[b]string or array, array of arrays of stringsrequired   The field to rename, if a new field name is given in as. From v1.106.0, multiple fields can be given using an array of old/new field name pairs: [[oldName1,newName1], [oldName2,newName2]].

[a] Optional parameters use their default value unless explicitly set.

[b] The parameter name field can be omitted.

Hide omitted argument names for this function

Show omitted argument names for this function

Note

When a field is renamed to a field that already exists, the existing field and its content is overwritten by the new field. The same happens when the field is renamed through field aliasing.

Old fields are removed from the event stream which can add overhead during processing. Copying to a new field using:

logscale
newfield := oldfield

is more efficient, but retains the old field in the event set.

rename() Examples

Click + next to an example below to get the full details.

Rename Fields

Rename fields to more readable names using the rename() function

Query
logscale
rename(field=[[src_ip, source_address], [dst_ip, destination_address], [src_port, source_port], [dst_port, destination_port]])
Introduction

In this example, the rename() function is used to rename multiple fields to more readable names.

Example incoming data might look like this:

timestampsrc_ipdst_ipsrc_portdst_portprotocolbytes_sentbytes_received
2025-04-01T07:00:00Z192.168.1.10010.0.0.5052431443TCP10242048
2025-04-01T07:00:01Z172.16.0.258.8.8.83322153UDP64512
2025-04-01T07:00:02Z192.168.1.150172.16.0.1004922380TCP20484096
2025-04-01T07:00:03Z10.0.0.75192.168.1.15567822TCP5121024
2025-04-01T07:00:04Z192.168.1.2001.1.1.14455653UDP64512
2025-04-01T07:00:05Z172.16.0.50192.168.1.25512343389TCP40968192
2025-04-01T07:00:06Z192.168.1.7510.0.0.10048751445TCP20484096
2025-04-01T07:00:07Z10.0.0.25172.16.0.75539928080TCP10242048
2025-04-01T07:00:08Z192.168.1.1258.8.4.43566753UDP64512
2025-04-01T07:00:09Z172.16.0.100192.168.1.504789121TCP5121024
Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    rename(field=[[src_ip, source_address], [dst_ip, destination_address], [src_port, source_port], [dst_port, destination_port]])

    Renames the fields src_ip, dst_ip, src_port, and dst_port to more readable field names. The original field names are replaced with the new field names.

    Since field is the unnamed parameter, the query could also look like this: rename([[src_ip, source_address], [dst_ip, destination_address], [src_port, source_port], [dst_port, destination_port]]).

  3. Event Result set.

Summary and Results

The query is used to rename multiple fields in one single operation. Renaming of fields is used for standardisation, normalization, and readability. Normalizing field names across different data sources is, for example, useful for joins. The rename() function is often used with the table() function.

For renaming existing fields in arrays, see Rename Existing Fields in Array.

Sample output from the incoming example data (only showing renamed fields):

destination_addressdestination_portsource_addresssource_port
10.0.0.50443192.168.1.10052431
8.8.8.853172.16.0.2533221
172.16.0.10080192.168.1.15049223
192.168.1.12210.0.0.7555678
1.1.1.153192.168.1.20044556
192.168.1.253389172.16.0.5051234
10.0.0.100445192.168.1.7548751
172.16.0.75808010.0.0.2553992
8.8.4.453192.168.1.12535667
192.168.1.5021172.16.0.10047891

Rename a Single Field - Example 1

Rename a single field using the rename() function with the as parameter to define the new name of the field

Query
logscale
rename(field=badName, as=goodName)
Introduction

The rename() function is used to rename one or more fields. In this example, only one field is renamed using the as parameter to define the new name of the field.

Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    rename(field=badName, as=goodName)

    Renames the field badName to goodName.

  3. Event Result set.

Summary and Results

The query is used to quickly rename single fields.

Rename a Single Field - Example 2

Rename a single field using the rename() function with assignment syntax to define the new name of the field

Query
logscale
goodName := rename(badName)
Introduction

The rename() function is used to rename one or more fields. In this example, only one field is renamed using the assignment operator (:=).

Step-by-Step
  1. Starting with the source repository events.

  2. logscale
    goodName := rename(badName)

    Renames the badName field to goodName by assigning the new value (variable name) to the field. The value on the right side of the assignment operator is set equal to the value on the left side of it.

  3. Event Result set.

Summary and Results

The query is used to quickly rename single fields.