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
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...