Splunk Search

Is there a function that concatenates result lines of strings?

koljalauterbach
New Member

Hi everyone!

I would like to format a result into a string and I don't even know where to start and if there even is a function for that ...

My results are a simple list of number/characters:

AD1234
AB2342
GD4787
...

What I would like to have is a formatted string like this:

("AD1234","AB2342","GD4787","...")

Is there a function that concatenates result lines?

Thanks in advance!

0 Karma

cmerriman
Super Champion

Try something like this to add the double quotes and parentheses around the string..

...
|mvcombine delim="\",\"" field_name
|nomv data
|rex field=field_name mode=sed "s/(.*)/(\"\1\")/"

the function |format will format a series like (field=value1) OR (field=value2) OR .... but also works with more complex solutions, also, like when there is more than one field.
https://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Format

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi
you have to use mvcombine and nomv, something like this

index=_internal 
| head 100 
| dedup source  
| table source 
| mvcombine delim=", " source 
| nomv source

Bye.
Giuseppe

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 ...