Splunk Search

Which of these searches is the best way to filter (by index, by source, or both)?

driekhof
Path Finder

Which of these would be the most efficient/fast/best way to start filtering for a search?

index=foo | ...

or

source="/var/log/bar/baz.log" | ...

or

index=foo source="/var/log/bar/baz.log" | ...

We're going to have an index that will have several **/*.log sources, each with similar but unique data formats. We'll always know the data source and index for these queries. I'm wondering the best way start my queries.

0 Karma
1 Solution

pradeepkumarg
Influencer
index=foo source="/var/log/bar/baz.log" | ...

http://docs.splunk.com/Documentation/Splunk/6.5.2/Search/Writebettersearches

From the documentation

Restrict your search to the specific host, index, source, source type, or Splunk server whenever possible. Read more about using fields in your searches in the next section.

View solution in original post

pradeepkumarg
Influencer
index=foo source="/var/log/bar/baz.log" | ...

http://docs.splunk.com/Documentation/Splunk/6.5.2/Search/Writebettersearches

From the documentation

Restrict your search to the specific host, index, source, source type, or Splunk server whenever possible. Read more about using fields in your searches in the next section.

driekhof
Path Finder

That still isn't clear to me whether specifying both helps any over just specifying the most specific which would be source in my case. I was thinking Splunk might already know that this source is only in this index and optimize it, or already index the sources. I guess I'd have to profile using just the source vs the index and the source to be sure. But thanks for the info.

0 Karma

DalJeanis
Legend

In this case, having the extra data is certainly not going to hurt, but really, you ALWAYS want to specify the index, because then splunk does not have to look ANYWHERE ELSE. Giving it the source as well as that helps it narrow further.

Splunk would have figured out - almost certainly, after a glance at the summary stats - that there were none of that source anywhere else, by checking all the other indexes. But why make it go to even that meager effort?

driekhof
Path Finder

Ok, makes sense. I was just being paranoid about writing the shortest, clearest most concise query possible. And wanted to make sure specifying both source and index wouldn't cause Splunk to do extra work.

0 Karma

DalJeanis
Legend

Good goal. In this case quite the reverse, I think. If you can limit the search to a single index, or a limited set of them, then you'll (in theory) save splunk a slight bit of time in the search parsing. Overall run time is unlikely to be affected much, again, in my somewhat limited experience.

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...