Splunk Search

Is there any way to search "search server=server1" more efficient like "user"?

indeed_2000
Motivator

Hi

I have SPL like below:

index="myindex" user
| rex field=source "\/data\/(?<product>\w+)\/(?<date>\d+)\/(?<server>\w+)"
| search server=server1

as we know first search "user" work more quickly but second one "server=server1" take long time specially on large data.

is there any way to search "search server=server1" more efficient like "user"?

Thanks

Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The expression server=server1 requires the server field to exist, which it doesn't until after the rex command runs.  You can, however, search for server1 as a string within the source field to reduce the number of events read from the index and filter further on the server field.

 

index="myindex" user source="data*server1*"
| rex field=source "\/data\/(?<product>\w+)\/(?<date>\d+)\/(?<server>\w+)"
| search server=server1

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The expression server=server1 requires the server field to exist, which it doesn't until after the rex command runs.  You can, however, search for server1 as a string within the source field to reduce the number of events read from the index and filter further on the server field.

 

index="myindex" user source="data*server1*"
| rex field=source "\/data\/(?<product>\w+)\/(?<date>\d+)\/(?<server>\w+)"
| search server=server1

 

---
If this reply helps you, Karma would be appreciated.

indeed_2000
Motivator

@richgalloway this string must be search on source field NOT content of log!

server name not exist in log file, it came from name of log file.

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Thanks for the correction (it's virtual Monday for me).  See my revised answer.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...