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

The rename() function can be used to rename fields or column headers to more standardised and readable names. It is possible to rename multiple fields in a single operation.

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. flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 0[\Add Field/] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
    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