Splunk Search

How can I rename items with SPL query?

uagraw01
Motivator

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

 

 

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
Motivator

@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
Motivator

@VatsalJagani I have some limitations here.

0 Karma
Get Updates on the Splunk Community!

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...