Splunk Search

How to trim information from search output?

jugarugabi
Path Finder

Hi, 

I am having the following query: 

index=* sourcetype=CustomAccessLog | table "host", "source"

 

The output is:

host source
server32.de.db.com /path/to/server/instances/IFM_RT_1/logs/subdir_logs/log.file
server31.de.db.com /path/to/server/instances/IFM_RT_2/logs/subdir_logs/log.file

 

I would need to alter the search query so that the output is becoming:

host source
32 IFM_RT_1
31 IFM_RT_2

 

Tried using the following for the IFM_RT_

index=* sourcetype=CustomAccessLog | rex field=_raw "(?<IFM_RT_>.*)", but I couldn't get the needed data. 

Can I have your help here?

 

Thanks!

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @jugarugabi,

you could try to use the following regexes:

index=* sourcetype=CustomAccessLog 
| rex field=source "(?<source>IFM_RT_\d*)"
| rex field=host "^server(?<host>\d+)"
| table host source

Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jugarugabi,

you could try to use the following regexes:

index=* sourcetype=CustomAccessLog 
| rex field=source "(?<source>IFM_RT_\d*)"
| rex field=host "^server(?<host>\d+)"
| table host source

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @jugarugabi,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...