Mastering Splunk Searches: Improve Searches by 500k+ Times: Andrew Landen
Mastering Splunk Searches: Improve Searches by 500k+ Times: Andrew Landen
Mastering Splunk
Searches:
Improve searches by
500k+ times
Andrew Landen
Sr Splunk Developer | Chevron
© 2019 SPLUNK INC.
Who is 1) Education
Physics, BS
Andrew Information Systems Security, MS
Landen? 2) Experience
Teaching (3 yrs)
Geophysics (2 yrs)
IT Security/Splunk (6 yrs)
3) Splunk Experience
Sr. Developer (4 yrs)
Splunk Architect, SAE/CSM at Splunk (2 yrs)
Sr. Splunk Developer with Chevron (present)
© 2019 SPLUNK INC.
https://answers.splunk.com/answers/686727/what-are-your-splunk-t-shirt-ideas.html
© 2019 SPLUNK INC.
Forward- During the course of this presentation, we may make forward‐looking statements
regarding future events or plans of the company. We caution you that such statements
Looking reflect our current expectations and estimates based on factors currently known to us
and that actual events or results may differ materially. The forward-looking statements
Statements made in the this presentation are being made as of the time and date of its live
presentation. If reviewed after its live presentation, it may not contain current or
accurate information. We do not assume any obligation to update
any forward‐looking statements made herein.
In addition, any information about our roadmap outlines our general product direction
and is subject to change at any time without notice. It is for informational purposes only,
and shall not be incorporated into any contract or other commitment. Splunk undertakes
no obligation either to develop the features or functionalities described or to include any
such feature or functionality in a future release.
Splunk, Splunk>, Turn Data Into Doing, The Engine for Machine Data, Splunk Cloud,
Splunk Light and SPL are trademarks and registered trademarks of Splunk Inc. in the
United States and other countries. All other brand names, product names, or
trademarks belong to their respective owners. © 2019 Splunk Inc. All rights reserved.
© 2019 SPLUNK INC.
Agenda and
Objectives
What are we going to talk about?
© 2019 SPLUNK INC.
Agenda
Search Process Overview
What are we going to Fast Search Types
talk about?
Segmentation/breakers: Major and
minor
Tstats
Multisearch
© 2019 SPLUNK INC.
Objective
What kind of results can I expect?
1 SPL size
Which part of the search
is taking the longest?
1. SPL size
• Indexed Inspect the normalized search
4 Results Size
• Subsearch: 10k/50k, 60s
TERM
• index=a1 TERM(f1=v1)
• | tstats count where index=a1 TERM(f1=v1) by _time span=1d
– TERM applies to raw, not datamodels: from DM.DM
Summary data
• index=summary | collect index=a1 testmode=t
• | loadjob SID
• | inputlookup a1.csv where f1=v1
System calls
• | metadata index=a1 type=hosts
• | rest /services/saved/searches/
© 2019 SPLUNK INC.
Segmentation
Indexed token event filtration
© 2019 SPLUNK INC.
• Minor: / : = @ . - $ # % \ _
Spaces are major breakers
Segmentation Example:
• [24/Oct/2019:09:11:01.404 -0500] src=127.0.0.1;50
• Ex: Find all events with a src ip of 127.0.0.1
index=a1 TERM(2019) TERM(src=127.0.0.*) TERM(50)
Exploring Segmentation
Splunk GUI highlights segmentation with mouseover
index=_internal
TERM(/en-US/splunkd/__raw/servicesNS/nobody/search/search/jobs/1566602122.150/
*)
index=_internal 1566602122.150
index=_internal TERM(b=717)
© 2019 SPLUNK INC.
TERM
Unique indexed values are the key to speed
© 2019 SPLUNK INC.
Usage:
Demo
© 2019 SPLUNK INC.
Demo
© 2019 SPLUNK INC.
| inputlookup b | `term("b=",b)`
term(2): stats count by $f$ | rename $f$ AS f | table f | eval f = "TERM($pre$".f.")" | return 999999 $f
Yields: (TERM(b=140122)) OR (TERM(b=143)) OR (TERM(b=3037)) OR (TERM(b=717)) OR
(TERM(b=771)) OR (TERM(b=916))
| inputlookup b | `values(b)`
values(1): stats count by $f$ | rename $f$ AS f | table f | return 999999 $f
Yields: (140122) OR (143) OR (3037) OR (717) OR (771) OR (916)
Multisearch and
Crossjoins
Dynamic searches using multiple data
sources
© 2019 SPLUNK INC.
| multisearch
[ search index=b
[search index=a TERM(src=8.8.8.8) | eval search="TERM(dest=".dest.")" | return 9 $search] ]
| inputlookup append=t A3 B1
B.csv A3 B2
| stats values(a) values(b)
A3 B3
| rename values(*) AS *
| stats count by a b | table
ab
Q&A
"The answer is only as good as the question."
Andrew Landen | Sr. Splunk Dev @
Chevron
© 2019 SPLUNK INC.
Thank
You
!Go to the .conf19 mobile app to