Splunk Search

How can I concatenate a single field's value across multiple rows into a single string?

jeskandarian
Engager

Search:

index=exp eventName="business:SelfServ-ChangeTrip" ChangeBookingEventType=ChangeBookingPayloadChunk hotelChangePayloadId="24c51841-8188-448b-9f4a-26f978ae4af9" 
| sort chunkSequence 
| fields payload

Results:

date       payload
XXXX       String 1-
XXXX       String 2-

I'd like the result to be:

date       payload
XXXX       String 1-String 2-

Obviously I don't care about the date, but I can't seem to get rid of it with fields -_* without messing up the entire search.

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Do something like this

 index=exp eventName="business:SelfServ-ChangeTrip" ChangeBookingEventType=ChangeBookingPayloadChunk hotelChangePayloadId="24c51841-8188-448b-9f4a-26f978ae4af9" 
 | sort chunkSequence | stats list(payload) as payload | nomv payload

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Do something like this

 index=exp eventName="business:SelfServ-ChangeTrip" ChangeBookingEventType=ChangeBookingPayloadChunk hotelChangePayloadId="24c51841-8188-448b-9f4a-26f978ae4af9" 
 | sort chunkSequence | stats list(payload) as payload | nomv payload

jeskandarian
Engager

This worked great except when the payload field contains a comma. When it runs into a comma the resulting string gets truncated. I imagine I can do something to "list(payload)" but not sure.

0 Karma

woodcock
Esteemed Legend

Works for me:

|noop|stats count as field|eval field="a,b,c,d,e" | makemv delim="," field | rex field=field mode=sed "s/c/c,/" | nomv field
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...