Splunk Search

How to create a search for the fields using regex?

damucka
Builder

Hello,

I have the following string pattern (source):

/trace/DB_BWP/xsengine_ls5925.30246.crashdump.20190312-213001.009072.trc

Now I need to create at search following fields:
- DBSID, being "BWP" in this case
- servis, being the "xsengine"
- filename, being "xsengine_ls5925.30246.crashdump.20190312-213001.009072.trc"

For the filename I managed to find the following:

 | rex field=source "(?<filename>[\w\d\.-]+$)"

But somehow I struggle with the first two ...

Kind Regards,
Kamil

Tags (2)
0 Karma
1 Solution

vnravikumar
Champion

Hi @damucka

Try like

| makeresults 
| eval log="/trace/DB_BWP/xsengine_ls5925.30246.crashdump.20190312-213001.009072.trc" 
| rex field=log "\/.+_(?P<DBSID>.+)\/(?P<servis>.+)\_(?<filename>.+)$" 
| eval filename = servis."_".filename

View solution in original post

vnravikumar
Champion

Hi @damucka

Try like

| makeresults 
| eval log="/trace/DB_BWP/xsengine_ls5925.30246.crashdump.20190312-213001.009072.trc" 
| rex field=log "\/.+_(?P<DBSID>.+)\/(?P<servis>.+)\_(?<filename>.+)$" 
| eval filename = servis."_".filename

damucka
Builder

Hi @vnravikumar

Thank you, it work fine.

Kind regards,
Kamil

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...