001 Now You Know Splunk (FreeCourseWeb - Com)
001 Now You Know Splunk (FreeCourseWeb - Com)
Splunk account
• Sign up for free at splunk.com
Linux machine
• Virtual machine or cloud instance
will work
• SSH access required
• Examples will be based on Ubuntu
Let’s Get Started >
What is Splunk?
• Software for searching, monitoring, and
analyzing machine-generated big data, via a
web-style interface
• Splunk (the product) captures, indexes and
correlates real-time data in a searchable
repository from which it can generate graphs,
reports, alerts, dashboards and visualizations
• E-learning course (free to take, so do it!)
• http://www.splunk.com/view/SP-CAAAH9U
Why Use Splunk?
• Security
• Collecting logs and finding “bad stuff”
• Operations
• Streamline operations
• Compliance
• PCI/SOX/HIPAA -> log review and retention
requirements
Who Uses Splunk?
What Are Logs?
This lab will be the foundation for the rest of the class
• Time to build a Splunk instance you can use for the examples
Let’s do it!
Your Lab System
Use this to
download Splunk
on your system
(cd to /tmp first)
Extract Splunk
• root@hostname:/opt# cd /opt
• root@hostname:/opt# tar -zxvf /tmp/splunk-7.0.3-fa31da744b51-Linux-
x86_64.tgz
• <lots of stuff extracting>
• When you’re done, it’ll look like something like this:
Start Splunk!
• Simply run /opt/splunk/bin/splunk start —accept-license
• In Splunk 7.1 and later - set admin password
Try Out Your New Splunk install!
• Go to http://<ip>:8000 in a web browser
Your First Search
• There’s no data in Splunk yet, so it’s not all that useful currently - but you
have internal logs you can search
And Audit Logs, Too!
Enable Splunk boot start
• Event
• Search
• Report
• Dashboard
• SPL
• Sourcetype
• Index
• Field Extractions
• Lookup tables
Event
severity_id severity
0 informa0onal
1 low
2 medium
3 high
4 cri0cal
Enough of Me Talking
Let’s Play With Some Data
Lab 2: Importing Data
• It’s not uncommon to be asked to work with a log type you’ve never seen
before - don’t be scared
• As long as it’s in a text format somewhere that can be read or accessed
by Splunk, we generally can work with it
• Some data types or log sources are much easier to work with than others
• Don’t re-invent the wheel - re-use existing work and techniques whenever
possible
Data Onboarding Approach
When you want to onboard a new data type, research to see what
information we already have about that log type
• Have we done this before?
• Is there a Splunk app available?
• https://splunkbase.splunk.com
• Is there any documentation available for working with this source?
• It’s generally helpful to ask the following questions:
• What index should store this data?
• What is the desired retention period?
• Who should have access to this data?
• Is there a sample log to review?
Experimenting With Data
• Protip - if you can’t find the config file location, try btool:
Splunk Infrastructure
Distributed Splunk Environments
Splunk Infrastructure/Servers
• Indexer
• Search Head
• Forwarder
• Universal Forwarder
• Syslog Receiver
• Deployment Server
• License master
• Splunk Clustering (Indexer, Search Head,
Multisite)
Core Splunk Infrastructure
Indexer
Indexer clustering:
• A specially configured group of Splunk Enterprise indexers that
replicate external data, so that they maintain multiple copies of the
data.
• Indexer clusters promote high availability and disaster recovery.
Index replication:
• A Splunk Enterprise feature that consists of clusters of indexers that
are configured to replicate data to achieve several goals: data
availability, data fidelity, disaster tolerance, and improved search
performance.
Think of indexer clustering as RAID for indexed data in Splunk
Multisite Clustering
Fields
• Selected
• Interesting
• All fields
Interesting fields are those that are present in at least 20% of
your events
• You may need to look at all fields to find something you are looking
for, depending on the events
Field Names and Values
• Create a search showing the top TCP/UDP ports passing through the
firewall from your machine over the past 15 minutes
• Experiment with different visualizations and limits on the search
• Save this search as a report
• Save As -> Report
• Title: <Your Name> Top Services
Working with Results
Reporting with Log Data
Lab 7: Tables
• Let’s pretend you have AWS instances that are exposed to the
internet
• Let’s also assume the firewalls on these instances allow SSH in from
the world
• For the sake of this example, let’s make a report of the users that are
trying to SSH in
• We’ll eventually turn this into a dashboard
Exploring the Logs
What do we know?
• index containing logs is os
• sourcetype is linux_secure
• How do we find the OS logs?
• Let’s search for it!
Let’s Explore the Fields Available
• Create a few tables using the firewall log and linux_secure data
• Save these searches as reports
Splunk Power Tools
Cooking With Gas
Lab 8: More Search Syntax
• Using the time picker, you can enter relative time syntax in the
“Advanced” selector
• A preview of the resulting date and time is shown under each text box
Relative Time Syntax
• You can also enter relative times using “earliest” and “latest” as fields
in your search string
• The time picker won’t update, but the time range below the search
box will reflect your chosen time range
• Unless there are no results, then you just see the end of your range
Relative Time Syntax
Examples:
• First of this year - “@y”
• First of next year - “@y+1y” or “+1y@y”
• Sunday of this week - “@w0” (or just “@w”)
• Sunday of last week - “-1w@w0” (or just “-1w@w”)
• Noon today - “@d+12h” or “+1d@d-12h”
• Start of the previous hour - “-1h@h”
• You could use “-1h@h” and “@h” as your earliest and latest times
to search the logs “during the previous hours”
Relative Time Syntax
• Beware - the commands used and the order they are used can have
a significant impact on search performance
• For more info, see Steve McMaster’s blog post:
• https://www.hurricanelabs.com/blog/splunk-search-optimization-
paleo-diet-spl
Expert Commands
You probably shouldn’t use these unless you know what you’re doing
transaction
• The transaction command finds transactions based on events that
meet various constraints.
map
• The map command is a looping operator that runs a search
repeatedly for each input event or result.
join
• Use the join command to combine the results of a subsearch with
the results of a main search. One or more of the fields must be
common to each result set.
Making Logs Pretty
Time for Some Dashboards
Lab 9: Building a Dashboard
• If you want to access your Splunk config later, archive your system: