Professional Documents
Culture Documents
07/12/2011
Operational Intelligence
Class Goals
Gain a deeper understanding of search and reporting concepts
Create efficient, well-formed searches
Perform calculations and evaluations on search results
Generate reports and charts
Correlate events with transactions
Create and use macros
Create and use lookups
Create and use summary indexes
Operational Intelligence
Course scenario
Examples used in this course are based on an online retail business
Searches and reports will be based on:
- Business analytics from the web access logs and lookups
- Internal operations information from mail and internal network data
Operational Intelligence
Operational Intelligence
Youll become familiar with the fields and characteristics of these data
sources as the course progresses
Operational Intelligence
Course Outline
1. Search Fundamentals
2. Getting Statistics
3. Analyzing, Calculating, and Formatting
4. Creating Charts
5. Correlating Events
6. Enriching Data with Lookups
7. Summary Indexing
8. Creating and Using Macros
Operational Intelligence
Section 1:
Search Fundamentals
Operational Intelligence
Section objectives
Review basic search commands
Review general search practices
Examine the anatomy of a search
Understand search language syntax concepts
Review fields and use the fields command
Create a table
Extract fields
Examine multi-value fields
Operational Intelligence
10
If 90% of your events include the word 'error' but only 5% include the
word 'sshd', and your events have both of these words, including 'sshd' in
your search terms will help more than 'error alone
Operational Intelligence
11
granted" !
Operational Intelligence
12
Anatomy of a Search
Disk
Intermediate
results table
Intermediate
results table
Final results
table
Summarize
into table of
top 10 users
13
Remove
column
showing
percentage
Searching and Reporting with Splunk 4.2
14
PIPE:
Take these events and
COMMAND:
Get some stats
PIPE:
Take these stats and
COMMAND:
Set values for the lost_revenue field
FUNCTION:
Get a sum
FUNCTION:
Create a string
ARGUMENT:
Get a sum of the price field
CLAUSE:
Call that sum lost_revenue
Operational Intelligence
15
ARGUMENT:
Format the string from values in the
lost_revenue field, insert commas
Fields review
Splunk automatically extracts important fields in these events
A few are highlighted below (there are many more!)
web access log
clientip
product_id
method
mail log
status
MID
mailfrom
network
proxy log
Operational Intelligence
cs_username
s_hostname
16
many fields
- Makes table-display cleaner by allowing you to remove unnecessary fields
Operational Intelligence
17
Operational Intelligence
18
Operational Intelligence
19
Create a table
The table command returns a
table formed by only the fields in
the arguments
Columns are displayed in the
same order of fields entered in the
command
- Column headers are field names
- Rows are field values
- Each row represents an event
Operational Intelligence
20
Rename fields
Use the rename command to
rename fields
Useful for giving fields more
meaningful names
Use quotes to rename to a phrase
- |
Operational Intelligence
21
your searches
You can also use the rex command to create permanent extractions via
Splunk> Manager >> Fields >> Extractions
Learn more about the regex format and using
the rex command in Splunk.com/base/
Documentation
Operational Intelligence
22
Operational Intelligence
23
Operational Intelligence
24
25
them into a single result where the given field is a multivalue field
-delim controls how values are combined
26
Operational Intelligence
27
Section 2:
Getting statistics
Operational Intelligence
28
Section Objectives
Understand the stats command
Preview reporting and charting commands
Display top and rare values for given fields
Use the stats command
Operational Intelligence
29
Operational Intelligence
30
Scenario callouts
Most of the examples for the remainder of this course relate to a specific
scenario
For each example, a question is posed that might be asked by a colleague
or manager in the company
- The answers live in the Splunk data!
- Example:
Operational Intelligence
31
32
Operational Intelligence
33
Operational Intelligence
34
Operational Intelligence
35
Operational Intelligence
36
Getting statistics
The stats command allows you to get statistics on your data
You can apply different functions to the stats command, depending on the
type of statistics youre trying to achieve
Common functions include:
- count
results!
- distinct_count, dc returns a count of unique values for a given field
- sum returns a sum of numeric values
- avg returns an average of numeric values
- list lists all values of a given field
- values lists unique values of a given field
Operational Intelligence
37
stats count
count returns the number of
occurrences of a given field
38
stats count(field)
Adding a field as an argument to
the count function returns the
number of occurrences for that
field
Operational Intelligence
39
Operational Intelligence
40
stats sum(field)
For fields with a numeric value,
you can sum the actual values of
that field
Whats the total time for all web requests per site visitor?
Operational Intelligence
41
stats avg(field)
The avg function averages numeric values of a named field
This example averages all the values of the time_taken field, grouped by
the action field
Whats the average time it takes the application to perform an update vs purchase?
Operational Intelligence
42
addcoltotals
The addcoltotals
command computes the
sum of all numeric values for
a given field
How many items are being removed from carts before purchase?
the column
Operational Intelligence
43
addtotals
The addtotals commands gets the
sum of numeric fields for each event
- Define a field name in which to place
the total value
- Optionally, specify only certain fields to
include in the sum
- In this example, the addtotals
command is applied to the rKB_PS
and wKB_PS fields
- By default, the command computes a
sum for all numeric fields in the event
Operational Intelligence
44
stats list(field)
What websites are the users accessing?
Operational Intelligence
45
stats values(field)
The values function creates a list
for each unique field value for a
given field
Operational Intelligence
46
Operational Intelligence
47
eventstats
In this example, we get sum of the price field
for each product ID when a customer
removes the item from the cart
- Set a new field for that value lostSales!
48
eventstats (cont.)
Whats our revenue loss due to removal from
shopping cart?
Operational Intelligence
49
Create a chart
Running this in the Advanced Charting view creates a chart of the report
- Notice that all three statistics are included; lostSales, averageLosses, and
difference!
- Sales only wants to know how each product compares against an average
Operational Intelligence
50
Operational Intelligence
51
Lab
Report on top and rare values
Use the stats command and associated functions
Use the eventstats command
Operational Intelligence
52
Section 3:
Formatting / Calculating
Operational Intelligence
53
Section Objectives
Understand the eval command
Perform calculations on values with eval!
Convert values
Round values
Format values
Use conditional statements
Further filter calculated results
Operational Intelligence
54
eval
Operational Intelligence
55
First, well use eval to convert the time_taken value into seconds
Operational Intelligence
56
57
Round values
But theres still too many pesky decimal points!
The round(field or number, decimals) function sets the value of a field to
the number of decimals you specify
- In this example, we divide the value of the reqTime field by 1000 then round to
2 decimal points.
Whats the average amount of time it takes to perform an update vs purchase?
Operational Intelligence
58
59
60
61
tostring considerations
Once youve converted a numeric value to a string, the resulting value is no
longer considered numeric
- Sorting columns of numbers and timestamps may not work
- Automatic drilldown will not work with post-reporting conversions on charts
More information on formatting using the tostring
function can be found at splunk.com/base/
documentation
Operational Intelligence
62
63
Conditional statements
The if function takes three arguments
- The first argument is a Boolean expression
- If it evaluates to TRUE, the result is the second argument
- If it evaluates to FALSE, the result evaluates to the third argument
Otherwise, group everything else into a value called Other
If the value of the usage field is Business
Operational Intelligence
64
Where command
Runs an eval expression to filter the results
- The result of the expression must be Boolean
- Keeps only the results for which the evaluation was successful and the Boolean
Operational Intelligence
65
Operational Intelligence
66
Lab
Convert field values
Round field values
Compare field values
Format field values
Use conditional statements
Filter results with the where command
Operational Intelligence
67
Section 4:
Charting
Operational Intelligence
68
Section Objectives
Identify chart types
Identify the chart command
Create a basic chart
Split values into multiple series
Define stacked mode
Omit null and other values from charts
Create a timechart
Chart multiple values on the same timeline
Format charts
Apply statistical functions
Group data with buckets
Create a rangemap
Operational Intelligence
69
Chart types
Column and bar charts
- Compare the frequency of field
values
single column
Line chart
- Show trends over time or another
field
Operational Intelligence
70
Pie chart
- Show the relationship of parts of
71
chart avg(bytes) over host by date_wday the host field is the x-axis and
the series is split by day of week
chart avg(bytes) by host the host field is the x-axis since theres no split for
the series
- Because the chart command is designed to return chartable results, the value of
Operational Intelligence
72
The count function counts the number of events for each product_name!
How many of each product are we selling?
Operational Intelligence
73
Chart split by
If you want to split the series, identify the x-axis field with over, then use by
to split the series by additional fields
In this example, we split the series by host!
Which hosts are the most active?
Operational Intelligence
74
Operational Intelligence
75
Operational Intelligence
76
Operational Intelligence
77
Operational Intelligence
78
Timechart
Time charts perform statistical aggregations against time
Trend behaviors and find anomalies over time
_time is always the x axis
You can optionally split data by another field
- each distinct value of the "split by" field is a separate series in the chart
Operational Intelligence
79
Basic timechart
This basic timechart displays the number of usage violations over the last
24 hours
Note the same functions and arguments youve used with stats and chart
apply
How many usage violations in
the last 24 hours?
Operational Intelligence
80
Operational Intelligence
81
Formatting options
With the multi-series mode set to combined, all fields share the y-axis
Operational Intelligence
82
Operational Intelligence
83
Operational Intelligence
84
Operational Intelligence
85
Operational Intelligence
86
Operational Intelligence
87
Bucket
The bucket command
puts continuous numerical
values in fields into
discrete sets, or buckets
This example displays
search results over a 7
day time span, but
buckets the results into 1
day chunks
- The bucket command is
applied to the _time field
Operational Intelligence
88
Bucket (cont.)
This example displays web
requests that result in an http
status other than 200, grouped by
host.
The bucket command is applied to
the count field, and grouped into
intervals of 50.
Operational Intelligence
89
Rangemap
Rangemaps are a single-value
report useful on dashboards
To create a rangemap
- Craft and save a search using the
rangemap command
- Add the saved search to a
dashboard panel
Operational Intelligence
90
Rangemap (cont.)
Apply the rangemap to the
lostrevenue field
Operational Intelligence
91
Rangemap (cont.)
Once you create and save the
search, create a panel for a
dashboard
Todays Lost Revenue
type
- Select the Saved search
- Add the panel
Operational Intelligence
92
Rangemap (cont.)
To display color based on your
specified ranges, you must add
the classField option to the
dashboard XML
- In the edit panel, click Edit name/
XML
- Add
<option name="classField">range</option>
93
Lab
Create a basic column chart
Create a multi-series chart
Work with formatting options
Create a timechart
Operational Intelligence
94
Section 5:
Correlating Events
Operational Intelligence
95
Section objectives
Identify transactions
Group events using fields
Group events using fields and time
Search with transactions
Report on transactions
Determine when to use transactions vs stats
Operational Intelligence
96
Transactions overview
A transaction is any group of conceptually related events that spans time
The events can come from multiple applications or hosts
- Events related to a single purchase from an online store can span across an
Operational Intelligence
97
98
Group by fields
Using the transaction
command, you can group and
create a single event when
certain fields have the same
value
You can create transactions
across multiple tiers (i.e., web
server, application server,
media server) provided a
common field is shared
(accountID, sessionID)
Operational Intelligence
99
www.something.com
- cs_username the username
associated with the request
Operational Intelligence
100
- maxpause=5m!
101
Examine a transaction
The example below is one of the transactions created by the search
The transaction
contains 7
individual events
Each event
shares the same
host and
username
Operational Intelligence
102
Operational Intelligence
103
Transaction-specific fields
The transaction command produces two additional fields, duration and
eventcount.
- The duration value is the difference between the timestamps for the first and last
Operational Intelligence
104
Operational Intelligence
105
Operational Intelligence
106
Reporting on transactions
You can use the same statistics and reporting commands with transactions
This example takes advantage of the duration field, showing a trend of
the mail queue slowing down over 4 hours, then beginning to correct
- Adding events to the transaction from additional hosts or sources would
Operational Intelligence
107
Transaction vs Stats
Use transaction when you need to see the events correlated together
Use stats when you just want to see the results of a calculation
Use transaction when you must define event grouping based on start/
end values
Use stats when you can group events based on a field value (eg by
src_ip)
When you can do it either way, choose stats because it is more efficient
- sourcetype=trade_entries
vs.
sourcetype=trade_entries | stats count by TradeID!
Operational Intelligence
108
Lab
Correlate events with transactions
Search and report on transactions
Operational Intelligence
109
Section 6:
Enriching Data with Lookups
Operational Intelligence
110
Section Objectives
Discover lookups
Examine a lookup file example
Create a lookup table
Define a lookup
Configure an automatic lookup
Use the lookup in searches and reports
Operational Intelligence
111
Lookups
Some data should not be indexed within Splunk
- Static or relatively unchanging data
Operational Intelligence
112
Operational Intelligence
113
114
Operational Intelligence
115
116
change permissions,
enable/disable, delete and
clone
Operational Intelligence
117
Operational Intelligence
118
Time-based lookups
lookups can also be time-based if
a field in the lookup table that
represents a timestamp
- Specify the name of the time field
Operational Intelligence
119
Advanced Options
Under Advanced options, you
can specify:
- The minimum number of matches
Operational Intelligence
120
This example calls a lookup that includes fields for a browser and os based
on the value of the useragent field
Operational Intelligence
121
Operational Intelligence
122
prod_lookup
Operational Intelligence
123
124
Operational Intelligence
125
Operational Intelligence
126
Lab
Upload a lookup file
Create a lookup table
Use the lookup in a search
Configure the lookup to run automatically
Use the automatic lookup in a search
Operational Intelligence
127
Section 7:
Summary Indexing
Operational Intelligence
128
Section objectives
Define summary indexing
Create and schedule a summary search
Populate a summary index
Run searches against a summary index
Identify gaps and overlaps in the summary index
Correct gaps and overlaps in the summary index
Operational Intelligence
129
Example: Show the number of page views and visitors each of your Web sites had over
the past 30 days, broken out by site
- Build a rolling report that shows aggregated statistics over long period of time
Operational Intelligence
130
index
Operational Intelligence
131
Searches or reports that may take several minutes or more to complete can be
generated quickly
Operational Intelligence
132
Each time the search runs, it saves the results since the last run into a summary
index that you designate.
Operational Intelligence
133
1.
2.
index
Operational Intelligence
Populating search
results are
formatted and
stored as statistics
134
Summary
index
135
Operational Intelligence
136
Operational Intelligence
137
- Search on index:
index=summary search_name=searchName| stats count by clientip | <additional commands>!
Operational Intelligence
138
splunkd outages
- If splunkd goes down for a significant amount of time, you could get gaps in your
Operational Intelligence
139
and
end time or a period and a saved search name, followed by the | overlap
Operational Intelligence
140
Correcting gaps
Use the backfill script fill_summary_index.py to correct gaps or backfill your
summary index
- Specify the App
- Specify a list of summary searches to backfill
- Or, specify to backfill all summary searches for the App
Use -dedup true to ensure the backfill script does not create duplicates
Operational Intelligence
141
To backfill a summary index that does not have any data, dont use dedup
More information on backfilling a summary index can
be found at splunk.com/base/documentation
Operational Intelligence
142
minutes
Manually delete the overlaps from the summary index by using the search
language.
Operational Intelligence
143
Lab
Search a summary index
Create a report from a summary index
Operational Intelligence
144
Section 8:
Macros
Operational Intelligence
145
Section Objectives
Understand macros
Manage macros
Create a basic macro
Use a basic macro
Define arguments / variables for a macro
Use arguments with a macro
Add and use multiple arguments with a macro
Operational Intelligence
146
Macros overview
Useful when you frequently run searches or reports with similar search
syntax
Chunks of a search you can reuse in multiple places
Can be any chunk of your search string or search command pipeline
Allows you to define one or more arguments within the search segment
- Pass values to the argument when using the macro
Operational Intelligence
147
Managing Macros
As with other types of knowledge
objects, you can:
Create new
Edit
Set permissions
Enable/disable
Clone
Move
Delete
Operational Intelligence
148
149
- `macroname`
- Do not confuse with single-quote
character ()
150
Adding arguments
Change one or more variables of
the macro at search time
Include the number of arguments
in parenthesis after the macro
name
- performance(1)
151
Using arguments
When using a macro with
arguments, include the argument
in parenthesis following the macro
name.
Operational Intelligence
sourcetype="access_*" host=$host$
| chart avg(time_taken) as reqTime by action
| eval reqTime = round(reqTime/1000, 2)!
152
Operational Intelligence
153
Operational Intelligence
154
Lab
Create a basic macro
Use the basic macro in a search
Create a macro with arguments
Use the macro and pass the arguments in a search
Operational Intelligence
155
156
Splunk Support
Contact Splunk Support email: support@splunk.com
File a case online
http://www.splunk.com/index.php/submit_issue
24/7 phone depending on support contract
IRC #splunk on EFNET servers
Operational Intelligence
157
.conf2011:
nd
The
2
Annual
Splunk
Worldwide
Users
Conference
August
15-17,
2011:
The
WesFn
St.
Francis,
San
Francisco
54+
sessions
:
SplunkAnswers
Computer
Lab
:
2
General
Sessions
:
BoF
Meetups
Alumni
rate:
$595
Buy
3
get
1
free!
Use
your
Splunk
EducaFon
credits
for
Splunk
University!
Register
today:
www.splunk.com/goto/conf2011
Searching and Reporting with Splunk 4.2
Operational Intelligence
Thank You
Please fill out the class survey
Operational Intelligence
159