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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...