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
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...