Splunk Search

Split semicolon separated event into many events

starbac
Explorer

Hello every one,

I have some data in Splunk server that is separated by semicolon ";"
String1=Int1;String2=Int2;String3=Int3...

I want to split this data into lines and get only the list of strings. Below a sample of what I want to get:
String1
String2
String3
...

Tags (1)
0 Karma
1 Solution

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval msg="String1=Int1;String2=Int2;String3=Int3" 
| makemv delim=";" msg 
| mvexpand msg
| rex field=msg "(?P<name>^[^=]+)"

OR

| makeresults 
| eval msg="String1=Int1;String2=Int2;String3=Int3" 
| eval temp= split(msg,";") 
| mvexpand temp 
| eval result = mvindex(split(temp,"="),0)

View solution in original post

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval msg="String1=Int1;String2=Int2;String3=Int3" 
| makemv delim=";" msg 
| mvexpand msg
| rex field=msg "(?P<name>^[^=]+)"

OR

| makeresults 
| eval msg="String1=Int1;String2=Int2;String3=Int3" 
| eval temp= split(msg,";") 
| mvexpand temp 
| eval result = mvindex(split(temp,"="),0)

starbac
Explorer

Nope, it doesn't change anything in my results (And yes, I have replaced msg with _raw)

0 Karma

vnravikumar
Champion

if possible can you post your query. In which field it contains the above said data

0 Karma

starbac
Explorer

index=index_name sourcetype="sourcetype_name" some_pattern_to_match | eval msg=_raw
| eval temp= split(msg,";")
| mvexpand temp
| eval result = mvindex(split(temp,"="),0)

0 Karma

vnravikumar
Champion

If possible can you post some sample events?

0 Karma

starbac
Explorer

jboss-server-prd;jms-queues;queue1=0;queue2=0;queue3=0

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Expected?

0 Karma

vnravikumar
Champion

try like

| makeresults 
 | eval msg="jboss-server-prd;jms-queues;queue1=0;queue2=0;queue3=0" 
 | rex max_match=0 field=msg "(?P<result>\w+)\=" |mvexpand result
0 Karma

starbac
Explorer

Works, thanks !

0 Karma

starbac
Explorer

But I have one problem with it, I have a queue named "active.queue1=0", with your query I get only queue1, do you know how to fix it please ?

0 Karma

vnravikumar
Champion

Hi

Try this and let me know

| makeresults 
| eval msg="jboss-server-prd;jms-queues;active.queue1=0;queue2=0;queue3=0" 
| eval temp=split(msg,";") 
| mvexpand temp 
| regex temp="(\=)" 
| eval result = mvindex(split(temp,"="),0)

starbac
Explorer

Great, it works thanks

0 Karma

starbac
Explorer

queue1

queue2

queue3

All I want to get is an event for each queue

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

Ready to make your IT operations smarter and more efficient? Discover how to automate Splunk alerts with Red ...