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

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...