Splunk Search

Separating the string in the field

mayank101
New Member

I have various search string under the field name entity:

        Entity
 1   ABC:BOOT2NDSUNQTR_MAINT4_sfsdfdsfsdf
 2   FSD:BOOT2NDSUNMONTH_MAINT3_erewrewre
 3    AFE:BOOTALLSUNMONTH_MAINT1_SecProd_DEV_sdfsdfdsf

and so on..
I want field such as BOOT2NDSUNQTR,BOOT2NDSUNMONTH_MAINT3 to be separated out and put it into a different field called jobname.Can you please help me in writing the regex for the same

Tags (1)
0 Karma

vnravikumar
Champion

Hi

Try this

| makeresults 
| eval test="ABC:BOOT2NDSUNQTR_MAINT4_sfsdfdsfsdf,FSD:BOOT2NDSUNMONTH_MAINT3_erewrewre,AFE:BOOTALLSUNMONTH_MAINT1_SecProd_DEV_sdfsdfdsf" 
| makemv test delim="," 
| mvexpand test 
| rex field=test "\:(?P<test>[\S]+)" 
| eval result=split(test,"_") 
| eval jobName =mvindex(result,0)."_".mvindex(result,1) 
| table jobName
0 Karma

Vijeta
Influencer

@mayank101 See example below

| makeresults |eval Entity=" ABC:BOOT2NDSUNQTR_MAINT4_sfsdfdsfsdf"| rex field=Entity "(?<jobname>\S+_\S+)_"
0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...