Splunk: General Concepts
Splunk JOINS
Joins in Splunk aren't direct analogues of SQL JOINS. In many cases they will incorrectly return the wrong or only partial results:
index=sales sourcetype=orders | join user [ search index=user_info ]- cross Index.- When not using
max=0 - When a Query hits the Subsearch Event Limit of
50,000 Rows. - When a Sub-Query hits the Subsearch Runtime Timeout of
60 Secondsthe Query will terminate and return early.
Splunk Architecture
Distributed Search:
- Search Head (Clusters) - used for Searching Peers. Combines results before returning them back (think Map-Reduce).
- Indexers - often clustered, these are responsible for indexing incoming data.
- Indexers can be Search Heads.
Resources and Links
- https://www.splunk.com/en_us/resources/splunk-quick-reference-guide.html
- https://community.splunk.com/t5/Splunk-Search/Join-on-one-to-many-with-max-0-still-only-returns-1-row-per/m-p/363959
- https://docs.splunk.com/Splexicon:Searchhead
- https://docs.splunk.com/Splexicon:Indexer
Code samples:
CCPU: Exam Overview
Notes I took before passing the Splunk - Core Certified Power User Exam.
Primarily using the Official Splunk STEP free coursework.
Personal Objectives
I've used Splunk in fairly limited ways, namely:
- For basic querying, filtering (often in tandem with some other Data Warehouse/Observability Tool like Snowflake SQL).
- Most good engineering teams emphasize the need for multiple lines of visibility since many Observability Tools might be momentarily unavailable or prone to (internal or vendor) error.
- Many teams didn't leverage Knowledge Objects.
- To compare one List against another.
- To review aggregated logs, logging.
- Setting or refining basic alarms (that've been Templated from org or company-wide boilerplate).
- But haven't done much (or been asked to do much with) Knowledge Objects, advanced Filtering, etc.
Exam Overview
The Splunk Core Certified Power User is a mandatory prerequisite for any higher Certification level (unlike the AWS Certification Paths which recommend a particular sequence but which also waive any formal requirements if you choose to take the tests).
Exam Topics
Splunk Core Certified Power User:
- Topic One: Introduction to Splunk
- Topic Two: Fields
- Topic Three: Time
- Topic Four: Statistical Processing
- Topic Five: Comparing Values
- Topic Six: Result Modification
- Topic Seven: Correlation Analysis
- Topic Eight: Introduction to Knowledge Objects
- Topic Nine: Creating Knowledge Objects
- Topic Ten: Field Extractions
- Topic Eleven: Data Models
Resources and Links
CCPU: Introduction to Splunk
Topic One.
- Default User Roles:
User,Power,Admin(in ascending order). - New Reports are
Privateand visible only for theOwner/User who created it, by default. - Default TTL:
7 days(saved Searches),10 Minutes(ad-hoc, default). - Search Results are displayed in Reverse Chronological Order with Timestamps according to the searching User's Settings.
- Search Terms aren't case sensitive.
termA termB=termA AND termBANDORNOTsupported- Evaluation order: Expressions with parenthesis,
NOT,AND,OR
searchis further used to filter results (notfilter- there's nofilterCommand in Splunk).- Knowledge Manager: by default, only a designated User with either the
AdminorPowerrole.- Knowledge Managers can share and promote Knowledge Objects.
Applevel permissions can also be modified to allow sharing and promoting Knowlege Objects.
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/10.0/search-commands/search
- https://help.splunk.com/en/splunk-cloud-platform/manage-knowledge-objects/knowledge-management-manual/10.3.2512/get-started-with-knowledge-objects/manage-knowledge-object-permissions
- https://help.splunk.com/en/splunk-cloud-platform/manage-knowledge-objects/knowledge-management-manual/10.3.2512/get-started-with-knowledge-objects/manage-knowledge-object-permissions#id_45c40c5b_9706_4e9d_bbc5_699ad5f101f7--en__Enable_a_role_other_than_admin_and_power_to_set_permissions_and_share_objects
Code samples:
CCPU: Fields
Topic Two.
- Renaming a Field (with
evalorrename) requires using the new name thereafter. source,host, andsourcetypeare the three default selected Fields in Splunk.- Fields that appear in at least 20% of results appear as Interesting Fields.
- Remove or add Fields using
fields -orfields(with or without+- without defaults to+), respectively. - Field Discovery extracts Fields during a
search.- Default fields are extracted at Index Time.
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.1/search-commands/rename
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/9.1/fields-and-field-extractions/when-splunk-software-extracts-fields
Code samples:
CCPU: Time
Topic Three.
timechartdefault Spans depend on the selected Time Range:24 hours-> default Span30 minutes1 hour-> default Span1 minute7 days-> default Span1 day
- The default time Fields are:
date_hourdate_mdaydate_minutedate_monthdate_seconddate_wdaydate_yeardate_zone
earliest,latesttime modifiers will override the Time Picker.bincorrect syntax is... | bin _time span=1mor... | bin _time span=1minswhen specifying a time span - thebinCommand must specify the Field_time.s_raw,_timeare Internal Fields.- Time Units,
earliest, andlatestare applied during the initial Base Search (and cannot therefore be used with a precedingmakeresults). Time Units supported in Splunk:- Minute:
@mor@min - Hour:
@h - Day:
@d - Week:
@wor@week(snaps to Monday) - Specific day:
@w0(Sunday) through@w6(Saturday) - Month:
@monor@month - Year:
@yor@year - The expression:
earliest=-30d@d latest=@dsnaps to the first, complete 30 Days preceeding and thelatestDay (rounded down).
- Minute:
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/9.0/fields-and-field-extractions/use-default-fields
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.2/search-commands/bin
Code samples:
CCPU: Statistical Processing
Topic Four.
stats- Multiple Fields can be returned with
by. - Aggregate Statistical Functions (
sum,values,listetc.) that are executed within astatsclause and returned as Field.
- Multiple Fields can be returned with
chart- Similar to
statsbut narrowed to summarize exactly one or two Fields. overandbywill typically produce the same result when usingchart.
- Similar to
top- Returns the top n (
limit=n) most common results for a Field.
- Returns the top n (
rare- Essentially the opposite of the
topCommand. - Returns the n (
limit=n) least common results for a Field.
- Essentially the opposite of the
eval- Evaluates an Expression and adds that result as a Field.
- Eval Functions (including Multivalue Eval Functions
mvjoin,mvdedup,round, etc.) that are analogous tostatsFunctions but that differ in functionality, use, and name.
sort- Sort results by a specified Field (ascending by default, using prefixed
-for descending sort).
- Sort results by a specified Field (ascending by default, using prefixed
| Name | Command | Type | Example |
|---|---|---|---|
|
|
Statistical Aggregate Function | |
|
|
Statistical Aggregate Function | |
|
|
Multivalue Function | |
|
|
Multivalue Function | |
Transformations:
over- specifies the Field that will be tracked on the x-asix of achart.by- splits or subsegments data from one Field by another.- This can be combined with
over.
- This can be combined with
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.1/search-commands/stats
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.4/search-commands/chart
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.4/search-commands/top
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.4/search-commands/rare
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.4/search-commands/eval
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.4/search-commands/sort
- https://help.splunk.com/en/splunk-enterprise/search/search-manual/9.0/create-statistical-tables-and-chart-visualizations/about-transforming-commands-and-searches
- https://help.splunk.com/en/splunk-cloud-platform/search/spl2-search-reference/evaluation-functions/multivalue-eval-functions
Code samples:
CCPU: Comparing Values
Topic Five.
Additional Eval Functions that are combined with the eval Command:
| eval ExampleIfField = if((status_msg="OK"), "Is OK", "Isn't OK")| eval ExampleValidateField = validate(status_code="200", "Not 200", status_msg="OK", "Not OK")| eval ExampleInField= if(in(status_code, "404", "500"), "Not good", "Is OK")| eval ExampleMatchField= if(match(status_code, "^[0-9]{3}$"), "Valid", "Invalid")| eval ExampleReplaceField= replace(status_code, "^[0-9]{3}$", "xxx")| fieldformat ExampleFieldFormatField=tonumber(status_code, 10)| fillnull value="I'm a default value"
Comments:
- When using
evalall Field names are Case Sensitive and require double-quotations ("") if quotes are used (e.g. - white spaces in Field name). - Use
isnull,isnotnullto filterNULLvalues in results.
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.1/evaluation-functions/evaluation-functions
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.1/search-commands/fieldformat
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/10.2/search-commands/fillnull
Code samples:
CCPU: Result Modification
Topic Six.
appendpipe- Append new (or merged) Field to the very bottom of a result.eventstats- Append new Field to every row of an existing result/Table.streamstats- A realtime, streaming,eventstatsvariant (with nearly the same syntax and Function support).xyseries- Converts results into a more suitable format for graphing. It's the inverse of theuntableCommand.untable- Converts results into a more suitable Table.foreach- iterate over Fields, values in a Multivalue Field, etc.
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.4/search-commands/appendpipe
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.4/search-commands/eventstats
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.4/search-commands/streamstats
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.4/search-commands/xyseries
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.4/search-commands/untable
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/9.4/search-commands/foreach
Code samples: