Splunk Search

Extract Multiple fields

jayeshrajvir
Explorer

Sample data

[A028 : 00]
[F037 : 928323177452]
[F038 : 456137]
[F039 : 0]

The query below is working but i wanted to merge, basically i wanted to use rex field=_raw just once. How to extract multiple fields

index=au_axs_common_log sourcetype=anz_axs_auth_core_log "[A028" |rex field=_raw "(\[F039\s*:(?.*?)\])"| rex field=_raw "\[A028\s*:(?.*?)\]" |stats count by axrc,vrc

Labels (1)
Tags (1)
0 Karma

jayeshrajvir
Explorer

jayeshrajvir_0-1647344653392.png

 

@venky1544 It fetches/matching all the four fields. I wanted to match only two fields. Can you please share your thoughts.

0 Karma

venky1544
Builder

Hi @jayeshrajvir 

PFB screenshot hope this helps 

| makeresults |eval new = "[A028 : 00]"
|append [|makeresults |eval new="[F037 : 928323177452]"]
|append [|makeresults |eval new="[F038 : 456137]"]
|append [|makeresults |eval new="[F039 : 0]"]
|rex field=new "(\[A028|\[F038)\s:\s(?<num>\d+)\]"

 

venky1544_0-1647348590034.png

 

0 Karma

venky1544
Builder

hi @jayeshrajvir 

try this regex \[\w+\s:\s\d+\]

just curious what are you doing with the regex coz there is no named group in the regex  ??

is this a tweaked query you pasted here 

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...