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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...