Splunk Search

Fetching alphanumeric value and numeric values in aline

Arani_Hari
Loves-to-Learn Lots

How to extract alphanumeric and numeric values from aline,  both are dynamic values

<Alphanumeric>_ETC_RFG: play this message: announcement/<numeric>

Labels (1)
0 Karma

Arani_Hari
Loves-to-Learn Lots

I tried below syntax but it's matching entire line but I want only "ID" value /(?<ID>\w+)_ETC_RFG

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Can you share your SPL and data. This example works

| makeresults
| eval line="SOMEALPHA9876NUMERIC_ETC_RFG: play this message: announcement/12345678"
| rex field=line "(?<ID>\w+)_ETC_RFG:.*/(?<NUM>\d+)"

 

0 Karma

Arani_Hari
Loves-to-Learn Lots

log line will be

05:02:05.213 Txt 46000 008a456b37de5982_ETC_RFG: (Q056) play this message id:announcement/4637825, duration:58

expecting Table like

008a456b37de5982 ETC RFG 4637825

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You are not really giving us sufficient information. The rex command that @bowesmana provided extracts the alphanumeric and numeric as you asked. Your "table" doesn't identify what the columns are called. Are ETC and RFG fixed non-varying constant strings? Do these need to be in separate fields in the table? Please clarify your requirement, although, tbh, you already appear to have been given a workable solution.

0 Karma

Arani_Hari
Loves-to-Learn Lots

sorry, if i confused. Yes, ETC and RFG are fixed and need to add in table

Log Line:

05:02:05.213 Txt 46000 008a456b37de5982_ETC_RFG: (Q056) play this message id:announcement/4637825, duration:58

 

i tired to get result with below query,  but not working properly 

index=dg_hdgf_yrgt "(Q056) play this message" | rex field=_raw "Txt\s+46000\s+(?<IDvalue>\w+)" | rex field=_raw "announcement/(?<messagefile>\d+)"
| where NOT isnull(messagefile)
| mvexpand IDvalue
| makemv IDvalue delim="_"
| eval IDvalue=mvindex(IDvalue,0)
| eval ENV=mvindex(IDvalue,1)
| eval LOB=mvindex(IDvalue,2)
| search LOB=RFG
| table IDvalue,ENV,LOB,messagefile
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=line "(?<ID>\w+)_ETC_RFG:.*/(?<NUM>\d+)"
| eval ETC="ETC", RFG="RFG"
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

regex101.com is a good site for testing regex

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...