Splunk Search

Storing a REGEX filed into a DataModel

robertlynch2020
Influencer

Hi All

I am looking for the best approach to an issues i have.

I have multiple files that start with the following.

mxtiming_<PID>_<HOST>_<NPID>.log                                                 
mxtiming_acg_<NPID>.log                                                                        
mxtiming_dap_<PID>_<HOST>_<NPID>.log  

etc...

So i have worked out the REGEX to take in all the strings into a DataModel.

(?<MX_TIMING_STRING>mxtiming\S*)\.log

From this i then create multiple additional fields off the "MX_TIMING_STRING" with regex again.

mxtiming_(?<STANDARD>\d*_[^_]*_\d*)
mxtiming_(?<ACCOUNTING>acg_\d*)
mxtiming_(?<DATAPUBLISHER>dap_*_\d*_[^_]*_\d*)

What i am trying to to is to get one type MXTIMING.TYPE to be = to STANDARD or ACCOUNTING or DATAPUBLISHER etc.. As pending on the regex it can only be one. So I want to store in the Datamodel the type type of file it is.

I have tried a few things. Like the eval functions + regex but nothing is working...

if(isnull(STANDARD),NONE ,"STANDARD")
if(isnull(ACCOUNTING),NONE ,"ACCOUNTING")
if(isnull(DATAPUBLISHER),NONE ,"DATAPUBLISHER")
...

Any ideas 🙂

0 Karma

robertlynch2020
Influencer

Hi

I have found a Hardcoded solution to this, that i am 50-50 with.

I have created multiple datamodles tables each filling in the blanks bit by bit and then i pass it on to the next datamodel.
So it is like filling in the swiss cheese, hower the only issue is when a new MXTIMING COMES along i will have to update the datamodel with new REGEX. This is the bit i dont like.

if(isnull(WAREHOUSE),NULL,"WAREHOUSE")
if(isnull(TYPE), if(isnull(RATE_CURVE),NULL,"RATE_CURVE"),TYPE)
if(isnull(TYPE2), if(isnull(REALTIMEREFRESH),NULL,"REALTIMEREFRESH"),TYPE2)
if(isnull(TYPE3), if(isnull(TRADE_REPOSITORY_ENGINE),NULL,"TRADE_REPOSITORY_ENGINE"),TYPE3)
if(isnull(TYPE4), if(isnull(OBJECT_REPOSITORY_RISK_ENGINE),NULL,"OBJECT_REPOSITORY_RISK_ENGINE"),TYPE4)
if(isnull(TYPE5), if(isnull(DATAPUBLISHER),NULL,"DATAPUBLISHER"),TYPE5)
if(isnull(TYPE6), if(isnull(ACCOUNTING),NULL,"ACCOUNTING"),TYPE6)
if(isnull(TYPE7), if(isnull(STANDARD),NULL,"STANDARD"),TYPE7)

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Free Professional Services for .conf26 Attendees

This year at .conf26, we are doing something a little different. We are bringing the best minds from ...

Defend at Machine Speed: Your Guide to Security Sessions at .conf26

Splunk .conf26   With threats moving at machine speed and attack surfaces expanding across hybrid ...

Where Innovation Takes Flight: The Splunk4Aviation Flight Sim Lands at .conf26

If you hear someone at .conf26 shouting "gear down, GEAR DOWN" across the show floor, you have found us.  The ...