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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...