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!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...