Getting Data In

Parse some text from log

claudio9494
New Member

Hi everyone,
i've got some log like this:

[2019-02-01 14:51:43][P][APPLICATION/controllers/access_controller.php:166  in access_controller::_get_authenticated_user()] [24418549=Laetitia resoludor] _get_authenticated_user -> session_start
[2019-02-01 14:51:43][P][APPLICATION/mappers/exam_mapper.php:15 SQL->query_single_row()  in exam_mapper::getExam()] [24418549=Laetitia resoludor] [DB] INIT: mysql:host=hidden.com;dbname=myapp
[2019-02-01 14:51:43][P][APPLICATION/mappers/exam_mapper.php:15 SQL->query_single_row()  in exam_mapper::getExam()] [24418549=Laetitia resoludor] [SQL][myapp/mysql] 
SELECT *
        FROM app_exam 
        INNER JOIN  app_qcm ON app_exam.id_qcm = app_qcm.id_qcm
        WHERE app_exam.id_exam = 4506873

[2019-02-01 14:51:43][P][APPLICATION/mappers/exam_mapper.php:15 SQL->query_single_row()  in exam_mapper::getExam()] [24418549=Laetitia resoludor] [SQL][myapp/mysql] 
[2019-02-01 14:51:52][P][APPLICATION/mappers/exam_login_mapper.php:231 SQL->query_all()  in exam_login_mapper::selectAllByIdExamWithoutXML3()] [24418549=Laetitia resoludor] [SQL][myapp/mysql] 
SELECT id_exam_sheet,  points, note, current_question, total_question,options
        FROM app_exam_login
        INNER JOIN app_exam_sheet ON app_exam_login.id_exam_login = app_exam_sheet.id_exam_login
        where app_exam_login.id_exam=4506873
        order by id_exam_sheet;

i need to parse the [24418549=Laetitia resoludor] the field inside the box bracket (numberfield=name) can change,
how i can do that?
i've find a regex that can do that "[0-9]\d+=([A-Z])\w+ \w+" how i can apply that to splunk search and reporting?

Tags (2)
0 Karma

rshah_splunk
Splunk Employee
Splunk Employee

You can use rex command to accomplish your task.

Ex. | rex field=_raw "[0-9]\d+=(?[A-Z]\w+\s+\w+)"

This will extract the value in field called "myfield"
Reference: https://docs.splunk.com/Documentation/Splunk/7.2.3/SearchReference/Rex,

0 Karma

claudio9494
New Member

thanks, how i can extract from all event ?

0 Karma

rshah_splunk
Splunk Employee
Splunk Employee

All event means ? Can you help me understand ?
Just to note that as we have provided field=_raw, we will be applying that regex on entire raw event.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...