Splunk Search

How to extract fields from the header?

mklhs
Path Finder

Hello,

I would like to leave the

"header.JMSDestination"="topic/testTopic/Durable-Non-Subscription/20"  

the last two fields extract us as a field by creating an eval function so that it looks like the following:
"Durable-Non-Subscription.20" Next step I would like to separate this variable again so that it looks like "Non-Subscription.20". Finally, I need two variables:

"Durable-Non-Subscription.20"
"Non-Subscription.20"

Thank you very much

0 Karma
1 Solution

manjunathmeti
Champion

If field header.JMSDestination contains different path with same structure in each events, then you can use this:

| makeresults 
| eval header.JMSDestination="topic/testTopic/Durable-Non-Subscription/20" | append [| makeresults 
| eval header.JMSDestination="nexttopic/nexttestTopic/nextDurable-Non-Subscription/20" ]
| rex field=header.JMSDestination "(?<feild1>[\w-]+/[\d]+)$" 
| rex field=header.JMSDestination "-(?<feild2>[\w-]+/[\d]+)$" 
| eval feild1=replace(feild1, "/", "."), feild2=replace(feild2, "/", ".")

View solution in original post

0 Karma

manjunathmeti
Champion

If field header.JMSDestination contains different path with same structure in each events, then you can use this:

| makeresults 
| eval header.JMSDestination="topic/testTopic/Durable-Non-Subscription/20" | append [| makeresults 
| eval header.JMSDestination="nexttopic/nexttestTopic/nextDurable-Non-Subscription/20" ]
| rex field=header.JMSDestination "(?<feild1>[\w-]+/[\d]+)$" 
| rex field=header.JMSDestination "-(?<feild2>[\w-]+/[\d]+)$" 
| eval feild1=replace(feild1, "/", "."), feild2=replace(feild2, "/", ".")
0 Karma

morethanyell
Builder

Try this

| makeresults 
| eval _raw = "\"header.JMSDestination\"=\"topic/testTopic/Durable-Non-Subscription/20\""  
| rex "testTopic\/(?<field1>[^\"]+)" 
| rex field=field1 mode=sed "s/\//./g" 
| rex field=field1 "Durable-(?<field2>.*)$" 
0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...