Splunk Search

Regex issue

cbiraris
Path Finder

Hi Team

i am trying to make below field regex which is coming in every single event. but its not allowing me to use same field name for 2 same type of entry as they coming in same single event.

for example:

{ "class1": { "student1": "123 rollnumber" }, "class2": { "student1": "123 rollno", "student2": "321 rollno" } }

1)class1 and class2 should be under Class field
if i search for class1 i should only find student 1 and related info. 
and 
if i search for class3  i should only find student 1 and related info. 

they will be in the field like class, student, number, and type of number 

Class fieldclass1class2 
student namestudent1student1 
number123123321
type of number rollnumberrollnorollno
Labels (1)
Tags (1)
0 Karma

cbiraris
Path Finder

can you give me example ?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @cbiraris ,

which kind of example? isn't the search I shared ok?

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @cbiraris ,

you should create your report with the last two fields in one and then separate them using a regex, something like this:

<your_search>
| rename Class.student_name AS student_name Class.number AS number
| rex field=number "^(?<number>\d+)\s(?<type_of_number>.*)"
| table student_name number type_of_number

Ciao.

Giuseppe

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...