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!

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