Splunk Search

rex extraction of multiple fields from a record

Rob_Jordan
Explorer

While the following extraction below works, I wanted to see if I could extract both custom fields EAR_FILE and DOMAIN_NAME in one rex step instead of initiating a second search and rex command.

"Initiating redeploy*.ear" | rex field=_raw "(?<EAR_FILE>\w*\.ear)" | search "Initiating redeploy*.ear"| rex field=_raw "(?<DOMAIN_NAME>\w\wdomain\d\d)"

Sample Records:

<May 01, 2010 9:38:10 AM CDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating redeploy operation for application, MyApp [archive: /tmp/tsdomain01/upload/MyApp.ear], to configured targets.> 
<May 01, 2010 9:50:01 AM CDT> <Info> <J2EE Deployment SPI> <BEA-260121> <Initiating redeploy operation for application, YourApp [archive: /tmp/tsdomain02/upload/YourApp.ear], to configured targets.> 

Thank you,

Rob

Tags (2)
2 Solutions

dwaddle
SplunkTrust
SplunkTrust

Without seeing the original event, it's hard to make a regex to pull both. But, as a general rule, this is possible. As an example, for the event "Green Eggs and Ham" you could do a regex similar to:

| rex field=_raw "(?<egg_color>[^\s]+)[Ee]ggs and (?<meat_type>[^\s]+)"

If you're going to be doing this type of extraction on a regular basis, it might be worth it to read up on setting these up permanently in props.conf/transforms.conf.

View solution in original post

0 Karma

Rob_Jordan
Explorer

dwaddle, thanks for the help. Based on your example above, I was able to get it to work with the following.

"Initiating redeploy*.ear" | rex field=_raw "(?<DOMAIN_NAME>\w\wdomain\d\d)/.*/(?<EAR_FILE>\w*\.ear)"

View solution in original post

0 Karma

Rob_Jordan
Explorer

dwaddle, thanks for the help. Based on your example above, I was able to get it to work with the following.

"Initiating redeploy*.ear" | rex field=_raw "(?<DOMAIN_NAME>\w\wdomain\d\d)/.*/(?<EAR_FILE>\w*\.ear)"
0 Karma

dwaddle
SplunkTrust
SplunkTrust

Without seeing the original event, it's hard to make a regex to pull both. But, as a general rule, this is possible. As an example, for the event "Green Eggs and Ham" you could do a regex similar to:

| rex field=_raw "(?<egg_color>[^\s]+)[Ee]ggs and (?<meat_type>[^\s]+)"

If you're going to be doing this type of extraction on a regular basis, it might be worth it to read up on setting these up permanently in props.conf/transforms.conf.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...