Splunk Search

Extraction: How to split the values and search for specific words?

bollam
Path Finder

Hello,
I have got a few events with the fields "Information" and "Name". Few events look like below, and I have many such events.

25/08/2018  Information="details-dist-Hyderabad,details-state-Telangana,others-info-testing,details-local-abc,others-testing-info" , Name="abc"
26/08/2018  Information="details-state-Karnataka,details-dist-Bangalore,others-info-testing,others-testing-info,details-local-xyz" , Name="xyz"

The values of the fields are not consistent and it might shuffle the position.
For an instance, The details-dist-Hyderabad in the first event is at position 1 but in the second event it is in the position 2.

I would like to extract the values which contain "details" to a new field and should be placed in a order. So I can use this field for the further extraction.

Output should look like below.

newField = "details-dist-Hyderabad,details-state-Telangana,details-local-abc"
newField = "details-dist-Bangalore,details-state-Karnataka,details-local-xyz"
Tags (4)
0 Karma
1 Solution

nadlurinadluri
Communicator

Hi @bollam,

Try this run anywhere search..

| makeresults a=1
| eval Information="details-dist-Hyderabad,details-state-Telangana,others-info-testing,details-local-abc,others-testing-info"
| append
[ makeresults a1=1
|eval Information="details-state-Karnataka,details-dist-Bangalore,others-info-testing,others-testing-info,details-local-xyz"
]
|rex max_match=0 field=Information "details-dist-(?P\w+)"
|rex max_match=0 field=Information "details-state-(?P\w+)"
|rex max_match=0 field=Information "details-local-(?P\w+)"
|eval newField="details-dist-".dist.",details-state-".state.",details-local-".local
|fields - dist,local,state

View solution in original post

nadlurinadluri
Communicator

Hi @bollam,

Try this run anywhere search..

| makeresults a=1
| eval Information="details-dist-Hyderabad,details-state-Telangana,others-info-testing,details-local-abc,others-testing-info"
| append
[ makeresults a1=1
|eval Information="details-state-Karnataka,details-dist-Bangalore,others-info-testing,others-testing-info,details-local-xyz"
]
|rex max_match=0 field=Information "details-dist-(?P\w+)"
|rex max_match=0 field=Information "details-state-(?P\w+)"
|rex max_match=0 field=Information "details-local-(?P\w+)"
|eval newField="details-dist-".dist.",details-state-".state.",details-local-".local
|fields - dist,local,state

bollam
Path Finder

@nadlurinadluri, It worked, Thanks for the quick help!!

0 Karma

nadlurinadluri
Communicator

Glad that it helped you 🙂 Happy Splunking!!

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