Splunk Dev

How do I use rex command here ?

harshal94
Engager

Following is the sample event:

2018-05-31 13:05:32.673, SQL_ID="5y1v8tznxf4t1", DBID="3602297620", SQL_TEXT="SELECT "MBLNR","MJAHR","BWART","MATNR","WERKS","LGORT","WAERS","DMBTR","MENGE","SGTXT","GRUND","BUDAT_MKPF","USNAM_MKPF" FROM "MSEG" WHERE "MANDT"=:A0 AND "BUDAT_MKPF" BETWEEN :A1 AND :A2 AND "WERKS"=:A3 AND "BWART" BETWEEN :A4 AND :A5", ELAPSED_TIME="2876.465675", TOTAL_TIME="5752.93135", EXEC="2"

Required Field is in bold.
I want ELAPSED_TIME as field and its value.

Tags (1)
0 Karma

poete
Builder

Please try this:

   | makeresults 
    | eval data="2018-05-31 13:05:32.673, SQL_ID=\"5y1v8tznxf4t1\", DBID=\"3602297620\", SQL_TEXT=\"SELECT \"MBLNR\",\"MJAHR\",\"BWART\",\"MATNR\",\"WERKS\",\"LGORT\",\"WAERS\",\"DMBTR\",\"MENGE\",\"SGTXT\",\"GRUND\",\"BUDAT_MKPF\",\"USNAM_MKPF\" FROM \"MSEG\" WHERE \"MANDT\"=:A0 AND \"BUDAT_MKPF\" BETWEEN :A1 AND :A2 AND \"WERKS\"=:A3 AND \"BWART\" BETWEEN :A4 AND :A5\", ELAPSED_TIME=\"2876.465675\", TOTAL_TIME=\"5752.93135\", EXEC=\"2"
    | rex field=data ", ELAPSED_TIME=\"(?<numValue>\d+\.\d+)\""
    | table data,numValue
0 Karma

FrankVl
Ultra Champion

This should do the trick:

| rex "ELAPSED_TIME=\"(?<ELAPSED_TIME>[^\"]+)\"
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...