Splunk Search

How can I rename items with SPL query?

uagraw01
Builder

Hello Splunkers,

How can i rename all the OrderNumber1, OrderNumber2, OrderNumber3 as OrderNumber. And Country1, Country2,Country4 as Country. I have attached the screenshot also. 

 

Appreciated in advance

IMG_20220429_191708__01.jpg

 

 

Labels (1)
0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@uagraw01 - Use the solution given by @gcusello  if you want to get one value out of all the fields.

If you want all values from those fields into a new multi-valued field, then you can try:

| eval Country = mvappend(Country1, Country2, ...)
| eval OrderNumber = mvappend(OrderNumber1, OrderNumber2, ...)

 

I hope this helps!!

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @uagraw01 ,

if the field numbers is fixed, you can use coalesce option:

 

| eval OrderNumber=coalesce(OrderNumber1,OrderNumber2,OrderNumber3), country=coalesce(country1,country2,country3)

 

Ciao.

Giuseppe

uagraw01
Builder

@gcusello I already tried this. But let me know is this a good approach ?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @uagraw01,

Yes, coalesce is very much used option.

Ciao.

Giuseppe

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@uagraw01 - You can use the same formula as part of props.conf EVAL statement as well.

0 Karma

uagraw01
Builder

@VatsalJagani I have some limitations here.

0 Karma
Get Updates on the Splunk Community!

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...