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!

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