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
- https://www.splunk.com/en_us/training/certification-track/splunk-core-certified-power-user.html
- https://docs.splunk.com/Splexicon:Knowledgemanager
- https://www.splunk.com/en_us/training/certification-track/splunk-core-certified-advanced-power-user.html
- https://tmc222.medium.com/splunk-core-certified-power-user-splk-1002-certification-experience-8b59dfc6f353
- https://www.examtopics.com/exams/splunk/splk-1002/view/
- https://quizlet.com/216854360/splunk-fundamentals-and-power-user-certification-flash-cards/
- https://quizlet.com/no/360840399/splunk-core-certified-power-user-flash-cards/
- https://quizlet.com/gb/334313903/splunk-core-power-user-flashcards/
- https://quizlet.com/327635266/splunk-fundamentals-2-flash-cards/
- https://quizlet.com/330849049/splunk-2-power-user-exam-flash-cards/
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.- Is executed immediately.
- Multiples can be combined.
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.tostring- affix prepends, specify format:"binary","hex","commas","duration"- e.g. -
"$".tostring(cost, "commas")
- e.g. -
tonumber- similarly formats numbers into string text with a supplied base.substr- isn't 0-indexed.coalesce- Consolidates two Fields with common Values into one (normalizing them/making their Fields uniform/consistent).
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
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.3/evaluation-functions/conversion-functions
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.3/evaluation-functions/text-functions
Code samples:
CCPU: Correlation Analysis
Topic Seven.
https://www.splunk.com/en_us/pdfs/training/correlation-analysis-course-description.pdf
correlate- calculates and displays Field correlations.append- appends the results of one query below another.appendcols- appends Fields from one result to another as a column.union- merges results.
Resources and Links
- https://www.splunk.com/en_us/pdfs/training/correlation-analysis-course-description.pdf
- https://help.splunk.com/en/splunk-cloud-platform/search/search-reference/10.4.2604/search-commands/correlate
- https://help.splunk.com/en/splunk-cloud-platform/search/search-reference/10.4.2604/search-commands/append
- https://help.splunk.com/en/splunk-cloud-platform/search/search-reference/10.4.2604/search-commands/appendcols
Code samples:
CCPU: Introduction to Knowledge Objects
Topic Eight.
Key Splunk Knowledge Objects (covered in this exam):
- Calculated Fields
- Macros
- Workflow Actions
- Pivot Data Models
- Reports
- Alarms
- Dashboards
- Field Aliases
All Splunk Fields returned from Events will populate in the Fields Sidebar.
- Calculated Fields can contain an
evalExpression. - Macros
- Are defined within the Settings > Advanced search > Search macros UI/UX Component.
- Named, reusable, functionalities.
- Support
evalandsearchExpressions.
- Workflow Actions
- Defined within the Settings > Fields > Workflow actions UI/UX Component.
- Intended to support follow-up analysis but don't themselves populate data into Splunk Fields.
- Support actions such as opening HTTP GET, POST operations in a new browser window.
- Reports can be scheduled.
Permissions:
- The
AdminUser Role is required to make a Knowledge Object available to all Apps. User,Power,Admin(in ascending order) can create Knowledge Objects to varying extents (as allowed by their permissions).- Default sharing options (in ascending order of visibility):
Private- Shared/Accessible only for creator User (READ,WRITE).App- Shared/Accessible by all Users in same App (READ,WRITEdepending on Role specifics)Global/All Apps- Accessible by all the Users of all deployed Splunk Apps (READ,WRITEdepending on Role specifics).
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/10.4/welcome-to-knowledge-management/what-is-splunk-knowledge
- https://docs.splunk.com/Documentation/Splunk/8.2.12/Pivot/IntroductiontoPivot
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/10.4/search-macros/use-search-macros-in-searches#b8262fda_633e_4346_8c8f_6b3404aa989c--en__Use_search_macros_in_searches
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/9.2/workflow-actions/about-workflow-actions-in-splunk-web
- https://help.splunk.com/en/splunk-enterprise/create-dashboards-and-reports/reporting-manual/10.4/reporting-overview/about-reports
- https://help.splunk.com/en/splunk-cloud-platform/manage-knowledge-objects/knowledge-management-manual/10.5.2605/get-started-with-knowledge-objects/manage-knowledge-object-permissions
Code samples:
CCPU: Creating Knowledge Objects
Topic Nine.
- Search by
tag:- Tag Name:
| search tag=myvalue - Specific Field Tag:
| search tag::host=production - Tags are defined within the Settings > Tags UI/UX Component.
- Tag Name:
- Field Aliases are applied after Field Extractions and before: Lookups, Tags
- Defined within the Settings > Fields > Field aliases UI/UX Component.
- Event Type
- Can be used to normalize Field Names, Tags and Field Extractions
- Categorizes Events based on
searchconstraints
- Search Time operations sequence (in order):
- Field Extractions
- Field Aliases
- Calculated Fields
- Lookups
- Event Types
- Tags
- Available Workflow Actions:
GET,POST,Search
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/spl-search-reference/9.4/search-commands/tags
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/9.4/get-started-with-knowledge-objects/the-sequence-of-search-time-operations
Code samples:
CCPU: Creating Field Extractions
Topic Ten.
- Field Extractions
- Regular Expression - uses RegEx to extract Fields
- These are automatically generated and suggested after one selects/highlights a part of Event text.
- Delimitters - uses a specified symbol (Comma, Space, etc.) to separate and extract data (from CSVs, etc.)
- Manually editing Regular Expressions within a Field Extraction locks the interface and prevents validation of the results.
- Splunk Capture Groups are equivalent to RegEx Capture Groups
- Importantly, Fields can be extracted before Indexing is complete (and afterwards).
- Regular Expression - uses RegEx to extract Fields
- Best Practices
- Avoid RegEx Backtracking - avoid RegEx Pipes, Quantifiers, Wildcards.
- Use Job > Inspect Job UI/UX Component to review costly Queries and optimize searches (akin to Explain,
plan)
Resources and Links
- https://help.splunk.com/en/splunk-cloud-platform/manage-knowledge-objects/knowledge-management-manual/10.3.2512/use-the-settings-pages-for-field-extractions-in-splunk-web/use-the-field-extractions-page
- https://help.splunk.com/en/splunk-cloud-platform/search/spl2-search-manual/expressions-and-predicates/about-splunk-regular-expressions
- https://help.splunk.com/en/splunk-cloud-platform/search/spl2-search-manual/expressions-and-predicates/about-splunk-regular-expressions#groups-quantifiers-and-alternation-0
- https://help.splunk.com/en/splunk-enterprise/search/spl-search-reference/10.4/search-commands/regex
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/10.4/use-the-field-extractor-in-splunk-web/build-field-extractions-with-the-field-extractor
Code samples:
CCPU: Data Models
Topic Eleven.
- Splunk Data Models are composed of one or more Datasets.
- They are hiearchical
- Child Data Sets can't remove Parent Constraints (they can only add to them)
- Typed:
event,search,transaction, andchild - Edited through the Data Model Editor
- Knowledge Object
- Can be uploaded, downloaded, or created
- Splunk Data Model Metadata is uploaded through the Settings > Data models > Upload Data Model button.
- Add
.jsonl,.csv, and other files through Settings > Add data in the Splunk UI/UX. - Splunk Pivots use Lookups or Data Models to create visualizations in Splunk.
Resources and Links
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/10.4/build-a-data-model/about-data-models
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/knowledge-management-manual/10.4/build-a-data-model/design-data-models
- https://help.splunk.com/en/splunk-enterprise/manage-knowledge-objects/pivot-manual/9.4/pivot-overview/introduction-to-pivot
Code samples: