Hi i need extract the below file name from extracted output
MDTM|07/02/2023 23:58:59.007|[SFTP:3460819_0:eftpos:10.18.168.158] READ: *MDTM /eftpos/prod/AR-100-01_20230702_PAY.zip 16883063270
file name :- AR-100-01_20230702_PAY.zip
i need extract the above file name using rex command
Or something like this
| makeresults
| eval msg="MDTM|07/02/2023 23:58:59.007|[SFTP:3460819_0:eftpos:10.18.168.158] READ: *MDTM /eftpos/prod/AR-100-01_20230702_PAY.zip 16883063270"
| rex field=msg "\w+:\s+\S+\s+(\/[^\/]+)*\/(?<filename>[^\s\/]+)"
Hi emzed , sorry for your command i have not received an output , Attached screen shot for reference.
I tested it on artificial data and I used a field "msg" in rex command. I thing you have data in the field "_raw".
You should use
| rex field=_raw "\w+:\s+\S+\s+(\/[^\/]+)*\/(?<filename>[^\s\/]+)"
or
| rex "\w+:\s+\S+\s+(\/[^\/]+)*\/(?<filename>[^\s\/]+)"
note: _raw field is default field for rex command
Something like
| rex "READ: \S+ (/[^/]+)*/(?<filename>[^\s/]+)
"READ: \S+ (/[^/]+)*/(?<filename>[^\s/]+)
Rex is about compromises. I have to make a few assumptions based on the illustrated sample data.
The expression contains two different repetition tokens. + means repeat at least once, up to any number of times. * means repeat zero to unlimited times. Parentheses in standard regex is just grouping. So, (/[^/]+)* matches /abc, /abc/def, /abc/def/ghi; but (/[^/]+)* zero-length string, so (/[^/]+)*/ also matches /.
Hope this helps.