Splunk 7.X Fundamentals Part 2 (IOD) PDF
Splunk 7.X Fundamentals Part 2 (IOD) PDF
Instructor on Demand
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
1 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Course Prerequisites
• To be successful in this course, you should have Note
In order to receive credit for this
completed: course, you must complete all lab
exercises.
– Splunk Fundamentals Part 1
host=www1, host=WWW1
Field values
(unless coming from a lookup)
Returns a small number of results from each index bucket matching the search
I/O intensive as the indexer looks through all of an index's buckets Up to 2 seconds per index
Super Sparse bucket
With a lot of data, with a lot of buckets, it can take a long time to finish I/O bound
index=network sourcetype=cisco_wsa_squid action=denied src_ip=10.2.3.11
The indexer checks all buckets to find results, but bloom filters eliminate those buckets
that don’t include search results Up to 10-50 index
Rare buckets/second
Use Cases: user behavior tracking
I/O bound
index=web sourcetype=access_combined sessionID=1234
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
27 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Search Job Inspector
• Tool allows you to examine:
– Overall stats of search (e.g., records processed and returned,
processing time)
– How search was processed
– Where Splunk spent its time
• Use to troubleshoot search’s performance and understand impact of
knowledge objects on processing (e.g., event types, tags, lookups)
• Any existing (i.e., not expired) search job can be inspected
Note
For more information, see:
docs.splunk.com/Documentation/Splunk/latest/Sear
ch/ViewsearchjobpropertieswiththeJobInspector
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
28 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Search Job Inspector – 3 Components
• Header
• Execution costs
• Search job properties
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
29 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Search Job Inspector – Header
Note
Although three values are
returned from this search, a
scatter chart can only show two
dimensions.
Note
Compare this with the two-
dimensional scatter chart from the
same search, shown on the
previous slide.
index=security sourcetype=linux_secure
| chart count over vendor_action
Stack Mode ON
Note
Functions and arguments used with stats and
chart can also be used with timechart.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
58 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
timechart Command – Multiple Values
• Splitting by the usage field, each line represents a unique field value
– Unlike stats, only ONE field can be specified after by
• y-axis represents the count for each field value
Note
Scenario index=network sourcetype=cisco_wsa_squid Using timechart, you can split by
What is the overall usage trend | timechart count by usage a maximum of one field because
for the last 24 hours? _time is the implied first by field.
Scenario
What is the overall usage trend
for the last 24 hours?
timechart command
index=web sourcetype=access_combined action=*
| timechart span=1h count by action
index=security sourcetype=linux_secure
| rare src_ip, user, vendor_action, app
• trendtype:
– sma - simple moving average
– ema - exponential moving average
– wma - weighted moving average
Note
Autocomplete displays functions in purple. Here
however, since it does not recognize sma as a
function, it is shown in black.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
75 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
trendline Command – Example
Scenario index=web sourcetype=access_combined action=purchase status=200
Display total sales and sales | timechart span=2h sum(price) as sales
trends over the past 24 hours. | trendline sma2(sales) as trend
index=security sourcetype=linux_secure
(fail* OR invalid)
| iplocation src_ip
| geostats globallimit=5 count by user
index=sales sourcetype=vendor_sales
VendorID > 4999 AND VendorID < 6000
| stats count as Sales by VendorCountry
| geom geo_countries featureIdField=VendorCountry
sourcetype=access_combined action=purchase
| stats sum(price) as count
| gauge count 0 5000 10000 15000
index=security sourcetype=linux_secure
(fail* OR invalid)
| chart count by src_ip
| sort -count
3
1
2
General Options
field-list=one or more numeric fields. Defines the numeric fields to be totaled.
(Default: all numeric fields)
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
92 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
addtotals Command – Example 1
• row=t (default) counts the index=sales sourcetype=vendor_sales
| chart count over product_name by VendorCountry
fields in each row under a | addtotals
fieldname="Total Per Product" A
column named "Total Per col=t B
Product” label="Total Per Country" labelfield=product_name C
A
C B
C B
• Type Operators
Arithmetic + - * / %
Concatenation +.
Note
Boolean AND OR NOT XOR For more info on common eval
functions, see
Comparison < > <= >= != = == LIKE http://docs.splunk.com/Documenta
tion/Splunk/latest/SearchReferenc
e/CommonEvalFunctions
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
98 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
eval Command – Convert Values
• This example report displays Scenario
What types of websites used the most bandwidth
the sum of bytes used for in bytes during the previous month?
field values
index=web sourcetype=access_combined product_name=*
A In this example, stats calculates action=purchase
A | stats sum(price) as tp, sum(sale_price) as tsp by product_name
the total list price and total sale B | eval Discount = round(((tp - tsp)/ tp)*100)
price by product_name | sort -Discount
| eval Discount = Discount."%"
B eval calculates the discount | rename tp as "Total List Price", tsp as "Total Sale Price",
product_name as Product
percentage and formats the
discount field
tostring(field,"option")
index=web sourcetype=access_combined
• Options: action=purchase status=503
| stats count(price) as NumberOfLostSales, A
– "commas": applies commas avg(price) as AverageLostSales,
If the number includes decimals, it sum(price) as TotalLostRevenue
| eval AverageLostSales =
rounds to two decimal places "$" + tostring(AverageLostSales, "commas"), B
TotalLostRevenue =
– "duration": formats the number as "$" + tostring(TotalLostRevenue, "commas") C
"hh:mm:ss"
– "hex": formats the number
in hexadecimal A B C
Alpha Numeric
0=0, "Unrated")
X3 Y3
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
112 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
eval function
• To count the number of events Scenario
Count the number of events that occurred yesterday where
that contain a specific field the vendor action was Accepted, Failed, or session opened.
Note
To view all of the functions for where, see:
http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Where?r=searchtip
where command
Report the number of events over the past 24
hours by IP address for a specific range of
addresses.
with wildcards
Note
As you've seen, the like operator can
also be used with the case function.
• Common constraints:
maxspan maxpause startswith endswith
in a specified field
index=web sourcetype=access_combined
• Transactions can cross multiple tiers | transaction JSESSIONID
A
B
events
index=web sourcetype=access_combined
- maxspan=10m | transaction clientip maxspan=10m maxpause=1m
- maxpause=1m
▸Maximum total time between events
▸If not specified, default is -1 (or no limit)
Note
Assumptions: Transactions spanning more than 10 minutes with
the same client IP are considered unrelated. Also, there can be
no more than one minute between any two related events.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
130 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
transaction Command – startswith/endswith
• To form transactions based on Scenario
Determine the length of time spent to complete a purchase
terms, field values, or by customers in the online store over the last 24 hours.
• A took 6.163
seconds
• B took 4.643
seconds
Note
For more information go to:
http://docs.splunk.com/Documenta
tion/Splunk/7.0.0/Knowledge/What
isSplunkknowledge
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
141 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
What is a Knowledge Manager?
• Oversees knowledge object creation and usage for a group or
deployment
• Normalizes event data
• Creates data models for Pivot users
Note
By default, objects for all owners
are listed.
Unix
Search CIM Network Web
Settings
Fields Sidebar
Event Actions
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
153 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Regex Field Extractions from Settings
Settings > Fields > Field extractions > Open Field Extractor
Note 8
10
12
15.Click Finish
14
Note
An extractions name is provided
by default. However, this name
can be changed.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
161 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Using the Extracted Fields
7
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
165 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Editing Regex for Field Extractions – Modify RegEx
8. Update the regular expression Warning
After you edit the regular
expression, you cannot go back to
9. Click Save the Field Extractor UI.
10
Note
For more information about directly
editing these objects go to:
http://docs.splunk.com/Documentation/
Splunk/7.0.0/Admin/Propsconf
http://docs.splunk.com/Documentation/
Splunk/7.0.0/Admin/Transformsconf
Settings
Fields Sidebar
Event Actions
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
169 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Delimited Field Extractions from Settings
Settings > Fields > Field extractions > Open Field Extractor
name 9
10.Click Rename 10
Field
11.Repeat these
steps for all fields
extraction
14.Click Finish>
13
sourcetype=cisco_firewall
sourcetype=cisco_wsa_squid
sourcetype=winauthentication_security
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
182 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Creating a Field Alias
Settings > Fields > Field Aliases >
New Field Alias
1. Select the app associated with
the field alias
2. Enter a Name for the field alias 1
field: 3
• Host
4
• Source
• Sourcetype existing field name new field alias
field alias
original field
Note
Output fields from a lookup table or
fields/columns generated from within a
search string are not supported.
1
4
B
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
195 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Using Tags
To use tags in a search, use the syntax: tag=<tag name>
Note
Must be a basic search (cannot
contain pipes or subsearches).
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
202 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Using the Event Type Builder
1. From the event details, select Event Actions > Build
Event Type
• Saved Reports
– Search criteria will not change
– Includes a time range and formatting of the results
– Can be shared with Splunk users and added to dashboards
Note
Test your search string before saving your macro.
You can check the contents of your macro with
keyboard shortcuts (Command-Shift-E on Mac OS
or Control-Shift-E on Linux or Windows) from the
Search bar in the Search page.
character
- `macroname` != ‘macroname’
- Do not confuse with single-quote
character (‘)
• Pipe to more commands, or
precede with search string
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
212 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Adding Arguments
• Include the number of
arguments in parentheses after
the macro name
- monthly_sales(3)
• Within the search definition, use
$arg$
- currency=$currency$
- symbol=$symbol$
- rate=$rate$
• In the Arguments field, enter
the name of the argument(s)
• Provide one or more variables
of the macro at search time
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
213 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Using Arguments
• When using a macro with arguments,
include the argument(s) in parentheses
following the macro name
• Be sure to pass in the arguments in the
same order as you defined them
sourcetype=vendor_sales VendorCountry=Germany
OR VendorCountry=France OR VendorCountry=Italy
| `monthly_sales(euro,€,0.79)`
sourcetype=vendor_sales VendorCountry=Germany OR
VendorCountry=France OR VendorCountry=Italy |
stats sum(price) as USD by product_name
| eval euro = "€" + tostring(USD*0.79, "commas")
| eval USD = "$" + tostring(USD, "commas")
Complete steps 1 – 6 as 3
described in the previous
example, Creating a GET
Workflow Action
4
6
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
222 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Creating a POST Workflow Action (cont.)
7. Enter the URI of where
the user will be directed
7
8. Open the link in a New
window or Current 8
window 9
of post
10. Provide post argument
11
parameters
11.Save
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
223 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Creating a Search Workflow Action
Settings > Fields > Workflow
actions> New
1
Complete steps 1 – 5 as described
2
in the previous example, Creating a
GET Workflow Action 3
Transactions
2
successful requests
View a field's
example values
SPLITCOL status
FILTER status = 503
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
254 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Data Model Search Datasets
• Arbitrary searches that
include transforming
commands to define the
dataset that they
represent
• Search datasets can also
have fields, which are
added via the Add Field
button
Note
Data model acceleration is
discussed later in this module.
Note
An HTML 5 supported browser
must be used to download data
models.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
262 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
Uploading a Data Model
TA Checkpoint
delivered, blocked,
action string Action taken by the reporting device. quarantined,
deleted, unknown
allowed, blocked,
action string The action taken by the network device.
dropped, unknown
– Fields
Alerts Java Virtual Machines (JVM)
and event category tags Application State Malware
• Leverage the CIM so that knowledge objects CIM Validation (S.o.S) Performance
Best Practice
Keep the CIM Reference Tables in
Splunk Docs page open in a
separate tab.
Note
For more information, see the Common
Information Model Add-on Manual:
http://docs.splunk.com/Documentation/CIM/latest/
User/Overview
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
277 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
datamodel Command
• Search against a specified data
model object
• Return a description of all or a
specified data model and its objects
• Is a generating command and
should be the first command in the
pipeline
Important
The object name and search keyword aren't valid unless
preceded by the data model name. The command search
cannot be substituted with a search string or name.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
278 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
datamodel Command – Example
| datamodel Web Web search | fields Web*
A B C D E
Dataset name
prepended to field
A• Command names in your data
B• Data model name
C• Data model dataset name
D• Command
E• Find field names with Web prefix
Note
When using the datamodel command, the data
model name and dataset name are case-
sensitive.
Generated for ([email protected]) (C) Splunk Inc, not for distribution
Splunk Fundamentals 2
279 Copyright © 2018 Splunk, Inc. All rights reserved | 14 June 2018
from Command
• Retrieves data from a data model or named dataset
• Must be the first command in a search
• Different than just using datamodel
– datamodelreturns all fields prepended with data model name
– from datamodel returns specified fields only
| from datamodel:"internal_server.splunkdaccess"