Splunk Lab Manual
Splunk Lab Manual
Manual
2. Login Screen
Please enter your username and password to be obtained by the instructor
Splunk Home is your interactive portal to the data and apps accessible from this
Splunk instance. The main parts of Home include the Splunk Enterprise navigation
bar, the Apps menu, the Explore Splunk Enterprise panel, and a custom default
dashboard (not shown here).
Apps
The Apps panel lists the apps that are installed on your Splunk instance that you
have permission to view. Select the app from the list to open it.
For an out-of-the-box Splunk Enterprise installation, you see one App in the
workspace: Search & Reporting. When you have more than one app, you can drag
and drop the apps within the workspace to rearrange them.
The Splunk bar in another view, such as the Search & Reporting app's Search
view, also includes an App menu next to the Splunk logo.
Settings menu
The Settings menu lists the configuration pages for Knowledge objects, Distributed
environment settings, System and licensing, Data, and Authentication settings. If you do
not see some of these options, you do not have the permissions to view or edit them.
User menu
The User menu here is called "Administrator" because that is the default user name
for a new installation. You can change this display name by selecting Edit account
and changing the Full name. You can also edit the time zone settings, select a
default app for this account, and change the account's password. The User menu is
also where you Logout of this Splunk installation.
Messages menu
All system-level error messages are listed here. When there is a new message to
review, a notification displays as a count next to the Messages menu. Click the X to
remove the message.
Activity menu
The Activity menu lists shortcuts to the Jobs, Triggered alerts, and System
Activity views.
Click Jobs to open the search jobs manager window, where you can view and
manage currently running searches.
Click Triggered Alerts to view scheduled alerts that are triggered. This
tutorial does not discuss saving and scheduling alerts. See "About alerts" in
the Alerting Manual.
Click System Activity to see Dashboards about user activity and status of the
system.
Help
Click Help to see links to Video Tutorials, Splunk Answers, the Splunk Support
Find
Use Find to search for objects within your Splunk Enterprise instance. Find performs
non-case sensitive matches on the ID, labels, and descriptions in saved objects. For
example, if you type in "error", it returns the saved objects that contain the term
"error".
These saved objects include Reports, Dashboards, Alerts, and Data models. The
results appear in the list separated by the categories where they exist.
You can also run a search for error in the Search & Reporting app by clicking
Open error in search.
Start searching
In this section, you start searching that tutorial data. This topic discusses
searches that retrieve events from the index.
Before you can start this section, you need to first download and add the tutorial
data.
What to search
1. Click Search in the App navigation bar.
2. In the Search landing page, Look at the What to search panel.
types. The three source types are Apache web access logs
(access_combined_wcookie), Linux secure formatted logs (secure), and the
vendor sales log (vendor_sales).
Most of this tutorial covers searching the Apache web access logs and
correlating it with the vendor sales logs.
Search assistant
You have data for an online store that sells a variety of games. Try to find out
how many errors have occurred on the site.
1. Open Splunk Search, and type buttercupgames into the search bar.
As you type, the Search Assistant opens. There are two parts to search
assistant: the matching search history and search help.
Search assistant suggests completions for your search based on terms it
matches in your event data. These search completions are listed under
Matching terms or Matching searches. It does not list terms or phrases that do
not exist in your event data. Search assistant also displays the number of
matches for the search term. This number gives you an idea of how many search
results Splunk will return. Here, buttercupgames appears in 36,819 events.
10
Here, search assistant also provides Steps to help you learn How to Search.
Step 1 explains searches to retrieve events with examples for searching with
terms, quoted phrases, boolean operators, wildcards, and field values. Step 2
introduces how to use search commands.
Search assistant has more uses after you start learning the search language.
When you type in search commands, search assistant displays the command
syntax and usage.
If you do not want search assistant to open automatically, click Auto Open to
toggle it off. You can click the down arrow below the search bar to open it back
up again.
Retrieve events from the index
1. Type in keywords to find errors or failures and use Boolean operators: AND,
OR, NOT.
buttercupgames (error OR fail* OR severe)
11
12
These are also default fields (host, source, sourcetype) that Splunk Enterprise
extracts from the data during indexing. They help to specify exactly which events
you want to retrieve from the index.
13
fields. While the From field will contain only a single email address, the To and Cc
fields have one or more email addresses associated with them.
In Splunk Enterprise, fields are searchable name and value pairings that
distinguish one event from another because not all events will have the same
fields and field values. Fields let you write more tailored searches to retrieve the
specific events that you want.
Extracted fields
Splunk extracts fields from event data at index-time and at search-time.
Default and other indexed fields are extracted for each event that is processed
when that data is indexed. Default fields include host, source, and sourcetype..
Splunk Enterprise extracts different sets of fields, when you run a search..
You can also use the field extractor to create custom fields dynamically on your
local Splunk instance. The field extractor lets you define any pattern for
recognizing one or more fields in your events.
1. Go to the Search dashboard and type the following into the search bar:
sourcetype="access_*"
Search for fields use the syntax: fieldname="fieldvalue" . Field names are
case sensitive, but field values are not. You can use wildcards in field values.
Quotes are required when the field values include spaces.
This search indicates that you want to retrieve only events from your web access
logs and nothing else.
14
This search uses the wildcard access_* to match any Apache web
access sourcetype, which can be access_common, access_combined, or
access_combined_wcookie.
15
These are events for the Buttercup Games online store, so you might recognize
other information and keywords, such as Arcade, Simulation, productId,
categoryId, purchase, addtocart, and so on.
To the left of the events list is the Fields sidebar. As Splunk Enterprise retrieves
the events that match your search, the Fields sidebar updates with Selected
fields and Interesting fields. These are the fields that Splunk Enterprise
extracted from your data.
16
Selected Fields are the fields that appear in your search results. The default
fields host, source, and sourcetype are selected. These fields appear in all the
events.
You can hide and show the fields sidebar by clicking Hide Fields and Show
Fields, respectively.
17
You see more default fields, which includes fields based on each event's
timestamp (everything beginning with date_*), punctuation (punct), and
location (index).
Other field names apply to the web access logs. For example, there are
clientip, method, and status. These are not default fields. They are
extracted at search time.
Other extracted fields are related to the Buttercup Games online store. For
example, there are action, categoryId, and productId.
4. Select action, categoryId, and productId and close the Select Fields
window.
The three fields appear under Selected Fields in the sidebar. The selected fields
appear under the events in your search results if they exist in that particular
event. Every event might not have the same fields.
18
The fields sidebar displays the number of values that exist for each field. These
are the values that Splunk Enterprise indentifies from the results of your search.
In this set of search results, Splunk Enterprise found five values for action, and
that the action field appears in 49.9% of your search results.
6. Close this window and look at the other two fields you selected, categoryId
(what types of products the shop sells) and productId (specific catalog number
for products).
19
Use this panel to view all the fields in a particular event and select or deselect
individual fields for an individual event.
20
This search uses the HTTP status field, status, to specify successful requests
and the action field to search only for purchase events.
You can search for failed purchases in a similar manner using
status!=200, which looks for all events where the HTTP status code is
not equal to 200.
sourcetype=access_* status!=200 action=purchase
status=200
action=purchase
categoryId=simulation
The count of events returned are the number of simulation games purchased.
To find the number purchases for each type of product sold at the shop, run this
search for each unique categoryId. For the number of purchases made each day
of the previous week, run the search again for each time range.
21
To find this number for the days of the previous week, you have to run it against
the data for each day of that week. To see which products are more popular than
the other, you have to run the search for each of the eight categoryId values and
compare the results.
22
You've seen before that search assistant displays type ahead for keywords
that you type into the search bar. It also explains briefly how to search.
2. Type a pipe character, " | ", into the search bar.
The pipe indicates to Splunk that you're about to use a command, and that you
want to use the results of the search to the left of the pipe as the input to this
command. You can pass the results of one command into another command in a
series, or pipeline, of search commands.
23
You want Splunk to give you the most popular items bought at the online store.
3. Under common next commands, click top.
Splunk Enterprise appends the top command to your search string.
24
4. Type the categoryId field into the search bar to complete your search.
sourcetype=access_* status=200 action=purchase | top categoryId
The count of events under the search bar indicates the number of events
retrieved that match the search for sourcetype=access_* status=200
action=purchase. The results of the top command appear in the Statistics
tab.
25
26
Column, Bar, and Pie charts are recommended for this data set.
3. Select Pie.
Now, your report looks like this:
27
You can turn on drill down to delve deeper into the details of the information
presented to you in the tables and charts that result from your search.
4. Mouse over each slice of the pie to see the count and percentage values for
each categoryId.
28
29
30
31
Lab 5 Subsearchs
Use a subsearch
This topic walks you through examples of correlating events with subsearches.
A subsearch is a search with a search pipeline as an argument. Subsearches are
contained in square brackets and evaluated first. The result of the subsearch is
then used as an argument to the primary, or outer, search.
Limit the top command to return only one result for the clientip.
32
This search returns one clientip value, which we'll use to identify our
VIP customer.
2. Use the stats command to count this VIP customer's purchases:
sourcetype=access_* status=200 action=purchase clientip=87.194.216.51 |
stats count, dc(productId) by clientip
This search used the count() function which only returns the total count of
purchases for the customer. The dc() function is used to count how many
different products he buys.
The drawback to this approach is that you have to run two searches each time
you want to build this table. The top purchaser is not likely to be the same person
at any given time range.
Example 2: With a subsearch
Here, the subsearch is the segment that is enclosed in square brackets, [ ]. This
search, search sourcetype=access_* status=200 action=purchase | top
33
Because the top command returns count and percent fields as well, the table
command is used to keep only the clientip value.
34
These results should match the previous result, if you run it on the same time range.
But, if you change the time range, you might see different results because the top
purchasing customer will be different.
35
into Splunk.
If you are not in Splunk Home, click the Splunk logo on the
Splunk bar to go to Splunk Home.
Get file tutorialdata.zip
Under Explore Splunk Enterprise, click Add data.
The Add Data view opens. The Add Data displays three options for
adding data, lists of common data types, and add-ons you can use
to extend Splunk Enterprise's capabilities to add data.
Under "How do you want to add data?", click Upload.
36
Because the tutorial data file is an archived data file, the next
step in the Add Data workflow changes from Set Sourcetype
to Input Settings.
3. Click Next to
Under Input Settings, you can override the default settings for
Host, Source type, and Index.
37
4.1. Select
4.2. Type in
5. Click Review to
38
6. Click Submit
7. .( PLEASE
8. To confirm that
39
40
41
This opens the Lookups editor where you can create new lookups or edit existing
ones.
1. In the Lookups manager under "Actions" for Lookup table files, click Add
new.
42
This takes you to the Add new' lookup table files view where you upload CSV
files to use in your definitions for field lookups.
2. To save your lookup table file in the Search app, leave the Destination app as
search.
3. Under Upload a lookup file, browse for the CSV file (prices.csv) to upload.
4. Under Destination filename, name the file prices.csv.
This is the name you use to refer to the file in a lookup definition.
5. Click Save.
This uploads your lookup file to the Search app and returns to the lookup table
files list.
43
Note: If Splunk does not recognize or cannot upload the file, check that it was
uncompressed before you attempt to upload it again.
44
2. Under Sharing for the prices.csv lookup table's Path, click Permissions.
This opens the Permission dialog box for the prices.csv lookup file.
4. Click Save.
45
46
File-based lookups add fields from a static table, usually a CSV file.
6. Under Lookup file, select prices.csv (the name of your lookup table).
7. Leave Configure time-based lookup and Advanced options unselected.
8. Click Save.
This defines prices_lookup as a file-based lookup.
47
4. Click Save.
Now, prices_lookup should be shared with Global permissions.
Make the lookup automatic
1. In the Lookups manager, under Actions for Automatic lookups, click Add
New.
48
This takes you to the Add New automatic lookups view where you configure the
lookup to run automatically.
49
6. Under Lookup input fields type in productId in both text areas under
Lookup input fields .
Splunk Enterprise matches the field in the lookup table (which is the one
specified on the left) with the field on the right (which is the field in your events).
50
7.1 In the first text area, type product_name, which contains the descriptive name
for each productId.
7.2. In the second text area, after the equal sign, type productName. This
renames the field to productName.
7.3. Click Add another field to add more fields after the first one.
7.4. Add the field price, which contains the price for each productId. Do not
rename this field.
51
1. Return to Search.
2. Run the search for web access activity.
sourcetype=access_*
3. Scroll through the list of Interesting Fields in the fields sidebar, and find the
price field.
52
1. Copy and paste or type in the previous subsearch example to see what the
VIP customer bought. This time, replace the productId field with productName.
sourcetype=access_* status=200 action=purchase [search
sourcetype=access_* status=200 action=purchase | top limit=1 clientip |
53
The result is the same as in the previous subsearch example, except that the VIP
customer's purchases are more meaningful with the added descriptive product names.
54
1. Select the time range Yesterday and run the following search
2.
sourcetype=access_* status=200 action=purchase [search
sourcetype=access_* status=200 action=purchase | top limit=1 clientip |
table clientip] | stats count AS "Total Purchased", dc(productId) AS
"Total Products", values(productName) AS "Product Names" by clientip |
rename clientip AS "VIP Customer"
55
56
57
You can open the report in the search view and edit the saved search's
description, permissions, schedule, and acceleration. You can also clone,
embed, and delete the report from this menu.
2. Click More Info.
You can view and edit different properties of the report, including its schedule,
acceleration, permissions, and embedding.
3. Look at the time range picker, located to the top left.
You saved this report with a time range picker. The time range picker lets you
change the time period to run this search. For example, you can use this time
range picker to run this search for the VIP Customer Week to date, Last 60
minutes, Last 24 hours just by selecting the Preset time range or defining a
custom time range.
58
When you save a new report, its Permissions are set to Private. This means
that only you can view and edit the report. You can allow other apps to view, or
59
1. Under Actions for the VIP Customer report, click Edit and select Edit
Permissions.
2. In the Edit Permissions dialog box, set Display For to App and check the
box under Read for Everyone.
60
This action gives everyone who has access to this app the permission to view it.
3. Click Save.
Back at the Reports listing page, you see that the Sharing for VIP Customer now
reads App.
61
62
In this example, calculate the number of views, purchases, and adds to cart for
each type of product.
This report requires the productName field from the fields lookup example. If
you did not add the lookup, refer to that example and follow the procedure.
1. Run this search:
sourcetype=access_* status=200 | chart count AS views
count(eval(action="addtocart")) AS addtocart
count(eval(action="purchase")) AS purchases by productName | rename
productName AS "Product Name", views AS "Views", addtocart AS "Adds to
Cart", purchases AS "Purchases"
63
This search uses the chart command to count the number of events that are
action=purchase and action=addtocart.
2. Use the Visualization view options to format the results as a column chart.
Instead of the chart command, this search uses the stats command to count the
user actions. Then, it uses the eval command to define two new fields which
64
calculate conversion rates for "Product Views to Purchases" and "Adds to cart to
Purchases".
Steps 2 to 6 reformat the visualization to overlay the Conversion series onto the
Actions series.
2. Click Visualization.
This is the same chart as in Example 1, with two additional series,
"viewsToPurchase" and "cartToPurchase".
65
4.1 Rotate the label -45 degrees and do not truncate the label.
4.2 Click Apply.
66
67
68
7.1 In the Save Report As dialog box, enter a Title, "Comparison of Actions and
Conversion Rates by Product".
7.2 (Optional) Enter a Description, "The number of times a product is viewed,
added to cart, and purchased and the rates of purchases from these actions."
8. Click Save.
69
Use the count() function to count the number of events that have the field
action=purchase. Use the usenull and useother arguments to make sure the
chart counts events that have a value for productName.
70
2. Click the Visualization tab and Format the X-Axis, Y-Axis, and Legend to
produce the following line chart.
71
3.1 In the Save Report As dialog box, enter a Title, "Product Purchases over
Time".
3.2 (Optional) Enter a Description, "The number of purchases for each product."
72
This example uses sparklines to trend the count of purchases made over time.
For stats and chart searches, you can add sparklines to their results tables.
Sparklines are inline charts that appear within the search results table and are
designed to display time-based trends associated with the primary key of each row.
See "Add sparklines to your search results" in the Search Manual.
This example requires the productName field from the fields lookup example. If
you did not add the lookup, refer to that example and follow the procedure.
1. Run the following search:
sourcetype=access_* status=200 action=purchase| chart sparkline(count) AS
"Purchases Trend" count AS Total by categoryId | rename categoryId AS
"Category"
This search uses the chart command to count the number of purchases,
action="purchase", made for each product, productName. The difference is that the
count of purchases is now an argument of the sparkline() function.
73
74
Lab 9 Dashboards
About dashboards
Dashboards are views that are made up of panels that can contain modules
such as search boxes, fields, charts, tables, and lists. Dashboard panels are
usually hooked up to saved searches.
After you create a visualization or report, you can add it to a new or existing
dashboard using the Save as report dialog box. You can also use the
Dashboard Editor to create dashboards and edit existing dashboards. Using the
Dashboard editor is useful when you have a set of saved reports that you want to
quickly add to a dashboard.
Change dashboard permissions
You can specify access to a dashboard from the Dashboard Editor. However,
your user role (and capabilities defined for that role) might limit the type of access
you can define.
If your Splunk user role is admin (with the default set of capabilities), then you
can create dashboards that are private, visible in a specific app, or visible in all
apps. You can also provide access to other Splunk user roles, such as user,
admin, and other roles with specific capabilities.
Change dashboard panel visualizations
After you create a panel with the Dashboard Editor, use the Visualization Editor
to change the visualization type in the panel, and to determine how that
visualization displays and behaves. The Visualization Editor lets you choose from
visualization types that have their data structure requirements matched by the
search that has been specified for the panel.
75
76
2. Click the Visualization tab and select the Pie chart type.
77
78
This creates a dashboard with one report panel. To add more report panels, you
can run new searches and save them to this dashboard, or you can add saved
reports.
View and edit dashboard panels
1. Click Dashboards in the app navigation bar.
This takes you to the Dashboards listing page.
79
You can Create a new dashboard and edit existing dashboards. You see the
Buttercup Games Purchases dashboard that you created.
2. Under the i column, click the arrow next to Buttercup Games Purchases to
see more information about the dashboard: What app context it is in, whether or
not it is scheduled, and its permissions.
You can use the quick links that are inline with the information to edit the
dashboard's Schedule and Permissions.
Add an input to the dashboard
1. In the Dashboards list, click Buttercup Games Purchases to return to that
dashboard.
80
In this view, you have edit buttons: Add Input, Add Panel, and Edit Source.
81
4. Click the Edit Input icon for the time range picker. It looks like a pencil.
This opens a set of input controls. The Time input type should be preselected.
Apply.
This optional step redefines the name of the input token for the time range picker.
Because the default names of input tokens are not very descriptive (field1, field2,
82
field3, and so on), you may want to do this when you give your dashboard
multiple inputs. It makes it easier to understand which input you are working with.
You can also optionally change the default time range for the picker by changing
the value of Default. Right now it defaults to All time.
In the next two steps you connect your dashboard panel to this time range picker.
6. In the new dashboard panel, click the Inline Search icon and select
Edit Search String.
The Edit Search dialog opens.
83
The panel is now hooked up to the shared time range picker input. The inline
search that powers the panel now uses the time range selected for the shared
time range picker.
As you add panels to this dashboard, repeat steps 6 through 8 to hook the new
panels up to the shared time range picker input.
You can have dashboards that offer a mix of panels that work with the shared
time range picker and panels that show data for fixed time ranges.
9. Click Done to save your changes to the dashboard.
84
85
86
87
The new panel is placed in the dashboard editor. You can click anywhere to
close the Add Panel sidebar menu or choose another report to add to the
dashboard.
Note: If you want the new panels to work with the shared time range picker input,
repeat steps 6 through 8 from the "Add an input to the dashboard" procedure to
connect them to that input.
88
9. Close the Add Panel sidebar and rearrange the panels on the dashboard.
While in the dashboard editor, you can drag and drop a panel to rearrange it on
the dashboard.
10.
Click Done.
89
After you complete the dashboard, you can Export to PDF and Print the
dashboards using the buttons to the upper right. You can also share the
dashboard with other users by changing its permissions.
90
This topic shows you how to create new data models based on the tutorial data. Data
models are created within Pivot and you need to have admin or power role to create
a data model.
91
This takes you to the Data Models management page. The Data Models
management page is a listing page of data models. If you have existing data models
in this Splunk Enterprise instance, this page lists them. Use this page to manage the
permissions, acceleration, cloning, and removal of existing data models. You can
also use this page to upload a data model or create new data models, using the
Upload Data Model and New Data Model buttons on the top right.
92
Use this page to create objects for the new data model, define their constraints and
attributes, arrange the objects in logical hierarchies, and manage them.
93
In the last lab, you created the data model "Buttercup Games".
This lab walks you through adding a root object for Buttercup Games
purchases.
Use the Edit Objects page to design a new data model or redesign an existing
data model. On the Edit Objects page, you can create objects for your data
model, define their constraints and attributes, arrange them in logical object
hierarchies, and maintain them.
94
constraint, which is a simple search that filters out events that are not relevant to
the object.
Let's create an object to track purchase requests on the Buttercup Games
website.
1. To define the data model's first event base object, click Add Object.
Your first root object can be either a Root event or Root search.
95
This defines the web access page requests that are purchase events.
After you provide Constraints for the event base object you can click Preview to
test whether the constraints you've supplied return the kinds of events you want.
96
6. Click Save.
97
The list of attributes for the root object include: host, source, sourcetype, and
_time. If you want to add child objects to client and server errors, you need to edit the
attributes list to include additional attributes.
98
Pivot views
Pivot is part of the Search & Reporting app.
Entering Pivot takes you to the Select a Data Model page, where you should
see a list of the data models if any have been created. For example, this list
99
includes the Buttercup Games data model that you created earlier in this
tutorial. It also includes two sample data models that track Splunk Enterprise
internal and audit logs.
If you view Pivot in smaller browser windows, the Search & Reporting app's
navigation bar is hidden. To use the navigation bar, click the menu icon on the
upper right. The navigation bar slides down.
100
2. Use the arrows under the i column to view information for Buttercup Games.
Clicking Edit objects takes you to the object editor for the Buttercup Games data
model.
4. Use the arrows under the i column to view the information for the objects.
101
102
Selecting an object from the Select a Data Object view takes you to the New
Pivot editor for that data model.
Components of Pivot
Visualization types: The left-hand vertical bar contains icons that represent
different visualization types. Selecting a different icon controls which Pivot builder
and report interfaces display. Visualization types are: Statistics Table (default),
Column Chart, Bar Chart, Scatter Chart, Bubble Chart, Area Chart, Line Chart,
Pie Chart, Single Value Display, Radial Gauge, Marker Gauge, and Filler Gauge.
Document Actions: The upper horizontal bar displays document-related
actions. These actions include:
Save as...: Save the current report as a new one (Report) or as a
103
104
Job Actions: The Pause and Stop buttons control the progress of the Pivot job.
Other actions include: Share, Export, Print, and Open in Search. Clicking
Open in Search opens the Search view and runs the current search string.
105
106
1. From the app navigation bar, select Pivot to enter the Select a Data Model
page.
2. In the data models list, click Buttercup Games.
This takes you to the Select an Object page.
The Buttercup Games data model has a root object to track Purchase Requests
from the game website. The Purchases object breaks down into Successful and
Failed purchases.
3. Select "Purchase Requests".
This opens a New Pivot editor for the Purchase Requests object.
107
By default, the Pivot Editor interface displays elements to define a pivot table.
There are four basic pivot element categories: Filters, Split Rows, Split Columns,
and Column Values. When you first open the Pivot Editor for a specific object,
only two elements will be defined:
A time range Filter element (set to All time).
A Column Values element (set to "Count of <object_name>".
This gives you the single value, which is the total count of events returned by the
object over all time. In this case, this count is the "Count of Purchase Requests".
4. Select the Single Value Display element from the visualization bar.
108
109
110
3. Select Yes to include the time range picker. (This should be the default.)
4. Click Save.
After the report saves, a window displays that "Your report has been created". You
can continue editing the current Pivot, add the pivot to a dashboard, change
additional settings for the saved report, or view the report.
5. Click View to view the report.
111
2. Use the arrow in the i column to view information about Total Purchase
Requests report.
112
2. Choose the Buttercup Games data model and select the Successful
Purchases child object.
113
114
1. Under Filter, click the pencil next to All time to open the time range picker.
115
(If this shows no events, you can select "All time" and continue.)
116
This opens a dialog box that lets you format the field.
117
118
119
4. In the Your Report Has Been Created dialog box, click View.
120
2. Choose the Buttercup Games data model and select the Successful
Purchases child object.
121
Visualization types are listed in the black sidebar that runs down the left-hand
side of the Pivot editor. By default, the statistics table visualization is selected
when you enter Pivot.
It can be helpful to begin building your pivot as a table and then switch over to
the visualization of your choice. When you switch between pivot visualization
types, Pivot will find the elements it needs to create the visualization, discard the
elements it does not need, and notify you when needed elements need to be
defined. This happens when you switch between tables and charts as well as
between chart types.
122
1. Under Split Rows, click + and select categoryId from the list.
123
124
Column charts use the first split row element in pivot table definitions to
provide their X-axis values. In this case, that Split Row is Category.
Column charts use the first column value element in pivot table definitions to
provide their Y-axis values. Here, that Column Value is Count of Successful
Purchases.
125
126
Mouseover a slice of the pie chart to view the metrics: Category, Count of
Successful Purchases, and percentage of the total Count of Successful
Purchases.
127
About dashboards
Splunk Enterprise makes it easy to interactively build and edit dashboards
without writing a single line of XML code.
Add a pivot you have just created to a new or existing dashboard:
You can jump right into dashboard creation after creating a pivot
visualization you like with the Create Dashboard Panel feature. It guides
you through the process of creating a dashboard panel based on the
search and adding it to a new or preexisting dashboard. When you finish,
you are still in the Pivot view.
Use the Dashboard Editor to create dashboards and populate them
with dashboard panels: You can also use the Dashboard Editor to edit
existing dashboards. This method of dashboard creation is useful if you
have a set of pivot reports that you want to quickly base a set of
dashboard panels upon.
128
129
130
You can Create a new dashboard and edit existing dashboards. You see the
Buttercup Games dashboard you just created.
2. Under the i column, click the arrow next to Buttercup Games to see more
information about the dashboard: What app context it is in, whether or not it is
scheduled, and its permissions.
131
There are also quick links to edit the dashboard's Schedule and Permissions
inline with the information.
To view the dashboard, click the dashboard's Title or select the Edit option
under Actions.
Note: If you click to view a dashboard and you cannot view it (or it displays
blank), check that you have read access to the data model. To do this, go to the
Manage Data Models view and edit the Permissions for the Buttercup Games
data model to share in the App.
132
In this view, you have edit buttons: Add Input, Add Panel, and Edit Source.
This adds a shared time range picker input to the dashboard editor.
133
4. Click the Edit Input icon for the time range picker. It looks like a pencil.
This opens a set of input controls. The Time input type should be preselected.
This optional step redefines the name of the input token for the time range picker.
Because the default names of input tokens are not very descriptive (field1, field2,
134
field3, and so on), you may want to do this when you give your dashboard
multiple inputs. It makes it easier to understand which input you are working with.
You can also optionally change the default time range for the picker by changing
the value of Default. Right now it defaults to All time.
In the next two steps you connect your dashboard panel to this time range picker.
6. In the new dashboard panel, click the Inline Pivot icon and select Edit
Search String.
The Edit Search dialog opens.
135
The panel is now hooked up to the shared time range picker input. The inline
search that powers the panel now uses the time range selected for the shared
time range picker.
As you add panels to this dashboard, repeat steps 6 through 8 to hook the new
panels up to the shared time range picker input.
You can have dashboards that offer a mix of panels that work with the shared
time range picker and panels that show data for fixed time ranges.
9. Click Done to save your changes to the dashboard.
136
137
138
Before you close the Add Panel sidebar menu, add a second report.
5. Click Purchases by Product.
139
140
Lab 15 Alerts
Create alerts
141
correspond to:
minute hour day month day-of-week
*/5 * * * *
Every 5 minutes.
*/30 * * * *
Every 30 minutes.
0 */12 * * *
*/20
* * * 1-5
0 9 1-7 * 1
When you select Run on Cron Schedule for the time range of a scheduled alert,
enter the earliest and latest parameters for a search. What you enter overrides
the time range you set when you first ran the search.
To avoid overlaps or gaps, the execution schedule should match the search time
range. For example, to run a search every 20 minutes the search's time range
should also be 20 minutes (-20m).
142
143
144
The alert runs every hour at the half hour. It collects an hour's worth of event
data, beginning an hour and a half before the search runs. When the scheduled
search kicks off at a designated time, such as 3:30 pm, it collects the event data
that was indexed from 2:00 pm to 3:00 pm.
1. From the Search Page, create a search and select Save As > Alert.
2. In the Save As Alert dialog, specify the following to schedule the alert:
Title: Alert Example (30 Minute Delay)
Alert Type: Scheduled
Time Range: Run on Cron Schedule
Earliest: -90m
Latest: -30m
Earliest and Latest values set the time that the search covers to a
period that begins 90 minutes before the search launch time,
ending 30 minutes before the search launch time.
Cron Expression: 30 * * * *
The alert runs every hour on the half hour
145
Set the triggering conditions when you set values for the Trigger condition field
in the Save As Alert dialog box, as described in the following subtopics.
146
147
4. Define an action that sends an email that includes the results of the
search.
When you configure a Send Email action that includes search results, the
email contains the results of the original base search. It does not include
the results of the custom search.
It might appear that you can get the same results if you specify instead, the
following search for the base search of a basic conditional search:
log_level=ERROR OR log_level=FATAL OR log_level=CRITICAL) | stats count
by log_level | search count > 10
However, a basic conditional alert based on this search provides different results.
The search results contain only log level values that are greater than 10. The
results from the advanced conditional search details the count for all log levels,
but triggers only when the log levels are greater than 10.
148
For the previous example, you can design a rolling-window alert with the same
base search and get similar results with the custom condition search. Set the
rolling window to a 10 minutes time span. When the real-time search returns 10
log level entries within the 10 minute time span, the alert triggers.
149
1. From the Search Page, create the following search. Select Last 24 Hours
for the time range:
index=_internal (log_level=ERROR OR log_level=WARN* OR
log_level=FATAL OR log_level=CRITICAL) | stats count as
log_events
150
151
152
Alert type
Scheduled
Search
Look for error events in the last twenty-four hours.
Schedule
Run the search every day at the same time. In this case, the search runs
at 10:00 A.M.
Trigger conditions
Trigger the alert action if the search has more than five results.
Alert action
Send an email notification with search result details.
Set up the alert
1. From the Search Page, create the following search. index=_internal "
error " NOT debug source=*splunkd.log* earliest=-24h latest=now
153
3. Specify the following values for the fields in the Save As Alert dialog box.
Title: Errors in the last 24 hours
Alert type: Scheduled
Time Range: Run every day
Schedule: At 10:00
Trigger condition: Number of Results
Trigger when number of results: is greater than 5.
4. Select the Send Email alert action.
5. Set the following email settings, using tokens in the Subject and Message
fields.
To: email recipient
Priority: Normal
Subject: Too many errors alert: $name$
Message: There were $job.resultCount$ errors reported on
$trigger_date$.
Include: Link to Alert and Link to Results
Accept defaults for all other options.
6. Click Save.
154
Trigger conditions
Trigger the alert if there are more than five search results in one minute.
Alert action
Send an email notification.
Set up the alert
1. From the Search Page, create the following search. index=_internal "
error " NOT debug source=*splunkd.log*
155
Alert type
Real-time
Search
Look for all errors in real-time.
Triggering condition
Check the alert search results for errors of type WARNING. Trigger the alert
action if results include any WARNING errors.
Alert action
List the alert in the Triggered Alerts page.
156
157
Lab 16 Macros
Define and use search macros
Search macros are chunks of a search that you can reuse in multiple places, including
saved and ad hoc searches. Search macros can be any part of a search, such as an
eval statement or search term, and do not need to be a complete command. You can
also specify whether or not the macro field takes
any arguments.
Definition is the string that your search macro expands to when referenced in another
search.
If the search macro requires the user to input arguments, they are tokenized and
indicated by wrapping dollar signs around the arguments; for example, $arg1$. The
arguments values are then specified when the search macro is invoked.
158
159
This search takes web traffic events and breaks them into sessions, using the
"makesessions" search macro:
sourcetype=access_* | `makesessions`
This search returns a report of the number of pageviews per session for each
day:
sourcetype=access_* | `makesessions` | timechart span=1d
sum(eventcount) as pageviews count as sessions
If you wanted to build the same report, but with varying span lengths, just save it
as a search macro with an argument for the span length. Let's call this search
macro, "pageviews_per_second(1)":
sourcetype=access_* | `makesessions` | timechart $spanarg$
sum(eventcount) as pageviews count as sessions
Now, you can specify a span length when you run this search from the Search
app or add it to a saved search:
`pageviews_per_second(span=1h)`
160
Lab 17 Lookups
Example of HTTP status lookup
This examples walks through defining a static lookup that adds two informational
fields, status_description and status_type, into your Web access events. This
lets you search for the events you want when you might not know the specific
error code. For example, instead of searching for all the server error codes, you
can use status="Server Error".
Upload the lookup table to Splunk Enterprise
1. Download the http_status.csv file:
http_status.csv
Here's a sampling of the file:
status,status_description,status_type
100,Continue,Informational
101,Switching Protocols,Informational
200,OK,Successful
201,Created,Successful
202,Accepted,Successful
203,Non-Authoritative Information,Successful
...
161
162
Lab 18 Workflows
Example - Google search from field values
Here's an example of the setup for a GET link workflow action that sets off a Google search on
values of the topic field in search results:
163
In this example, we set the Label value to Google $topic$ because we have a field called
topic in our events and we want the value of topic to be included in the label for this workflow
action. For example, if the value for topic in an event is CreatefieldactionsinSplunkWeb the
field action displays as Google CreatefieldactionsinSplunkWeb in the topic field menu.
The Google $topic$ action applies to all events.
164
The Google $topic$ action URI uses the GET method to submit the topic value to Google for
a search.
whether the link shows up in the field menu, the event menu, or both.
whether the link opens the WHOIS search in the same window or a new one.
restrictions for the events that display the workflow action link. You can target the
workflow action to events that have specific fields, that belong to specific event types, or
some combination of the two.
165
Use Apply only to the following event types to identify one or more event types. If you
identify an event type, the workflow action only appears in the event menus for events
that belong to the event type.
5. For Show action in determine whether you want the action to appear in the Event menu, the
Fields menus, or Both.
6. Set Action type to Link.
7. Under URI provide the URI for a web resource that responds to POST requests.
8. Under Open link in, determine whether the workflow action displays in the current window
or if it opens the link in a new window.
9. Set Link method to Post.
10. Under Post arguments define arguments that should be sent to web resource at the identified
URI.
These arguments are key and value combinations. On both the key and value sides of the
argument, you can use field names enclosed in dollar signs to identify the field value
from your events that should be sent over to the resource. You can define multiple
key/value arguments in one POST workflow action.
Enter the key in the first field, and the value in the second field. Click Add another field
to create an additional POST argument.
11. Click Save to save your workflow action definition.
Splunk Enterprise automatically HTTP-form encodes variables that it passes in POST link
actions via URIs. This means you can include values that have spaces between words or
punctuation characters.
166
Note that the first POST argument sends server error $http_status$ to a title field in the
external issue tracking system. If you select this workflow action for an event with an
167
http_staus
of 500, then it opens an issue with the title server error 500 in the issue tracking
system.
The second POST argument uses the _raw field to include the multiline python stacktrace in the
description field of the new issue.
Finally, note that the workflow action has been set up so that it only applies to events belonging
to the errors_in_500_range event type. This is an event type that is only applied to events
carrying http_error values in the typical HTTP error range of 500 or greater. Events with
HTTP error codes below 500 do not display the submit error report workflow action in their
event or field menus.
168
Lab 19 Tagging
Tagging
Tags are used to label specific values of a ffield. For example, many names of servers
may not be immediately recognized, and using a tag format can help them be more
easily recognizable or distinguishable from each other.
To tag the value of a ffield, use the following steps:
1. Go to Settings | Tags. A window will open, as shown in the
following screenshot:
Adding Tags
169
4. You will now see your tag listed as shown in the following screenshot:
170
5. Go back to the event list and click the > sign next to an event. You will see
details of the event open up in a way similar to that presented in the following
screenshot. You can see here that itemid=EST-14 has been tagged as ITEM14.
Now everywhere that EST-14 occurs, it will be tagged as ITEM14.
Tags enable you to search more easily and to convey meaning about the field
values. When you search tag=ITEM14, all the cases where itemid=EST-14
show up. By using tags in this manner, you can facilitate your analysis.
171
As an example of how to create an Event type, take the following steps using
the buttercupgames ile:
172
3. Click Save As | Event Type in the upper-right corner of the screen and
create a name for the event type. In this case, we have used the name success.
4. In this screenshot, when we enter buttercupgames | stats count by
eventtype, we get a count of each event type. In this case, we have only one
event type, so we get only one count in our table, but we could easily put
other event types in:
173
5. If you want to remove an event type, go to Settings | Event types, and you will
get a screen similar to what is shown in the following screenshot. Just ind the
event type you want to remove and click on Delete:
Event Types (Notice that you can Delete the one you just made.)
174