Splunk Fundamental
Event
An event is:
One log entryExamples:
Failed password for invalid user fakeuserSOC-LAB-DAY2-TESTEvery line Splunk indexes is generally an event.
Host
Host answers:
Which machine created this event?Examples:
ubuntu-server
kali
windows
pfsenseCurrent Lab:
Hosts = 1
ubuntu-serverMemory Trick:
Host = MachineSource
Source answers:
Which file did this event come from?Examples:
/var/log/auth.log
/var/log/syslog
/var/log/apache2/access.logCurrent Lab:
/var/log/auth.log
/var/log/syslogMemory Trick:
Source = FileSourcetype
Sourcetype answers:
What kind of log is this?Examples:
linux_secure
syslog
apacheCurrent Lab:
linux_secure
syslogMemory Trick:
Sourcetype = Type of logHow is Apache a log I donβt understand it?
You don't know what Apache is.
What is Apache?
Apache is a program.
Just like:
Chrome = web browser
Discord = chat app
Apache = web server
A web server's job is to host websites.
For example, when you visit a website:
www.example.comthere might be an Apache server in the background sending you the webpage.
Apache creates log files
Apache keeps records of who visits the website.
Example:
Bob visited the homepage.
Sarah visited the login page.
John got a 404 error.It writes those records into a file called:
access.logIn Splunk
Splunk looks at access.log and says:
"I recognize this format. This came from Apache."
So Splunk labels it:
sourcetype=apacheThe easiest way to remember it for your lab
Don't worry about the technical details.
Just memorize:
File | Sourcetype |
|---|---|
auth.log | linux_secure |
messages | syslog |
access.log | apache |
For the lab, when you see:
/var/log/apache2/access.logthink:
π Web server log
π Apache
π sourcetype = apache
Let me check one thing:
When your lab asks for sourcetype, are they giving you a filename like:
/var/log/apache2/access.logand asking you to pick the sourcetype?
Or are they showing actual log entries and asking you to identify them?
Those are learned differently.
no but the sourcetype would be apache2 not access.log right
AH! Now I see where the confusion is.
You're mixing up source and sourcetype.
Take this path:
/var/log/apache2/access.logBreak it apart:
apache2 = folder
access.log = fileNeither one automatically equals the sourcetype.
In many Splunk labs, they map like this:
Source: /var/log/apache2/access.log
Sourcetype: apacheWhy not apache2?
Because apache2 is just the folder name. Splunk cares about the format of the log data, not the folder name.
Think about it:
/var/log/apache2/access.logcould be moved to
/home/zakari/logs/access.logand it would still contain Apache web server logs.
The log format didn't change.
So:
Source = where the file is located
Sourcetype = what kind of log data is inside
For your Splunk training, if you see:
/var/log/apache2/access.logthe answers are usually:
Source = /var/log/apache2/access.log
Sourcetype = apacheEVEN BETTER EXPLANATION
but how do we know that Source: /var/log/apache2/access.log Sourcetype: apache the source type is apache is it because apache2 is in the source?
Excellent question.
And the answer is:
No. Not necessarily.
This is a very important distinction.
Let's look at this:
/var/log/apache2/access.logFrom the filename, we can guess it's an Apache log.
But Splunk does not automatically know that:
Source = /var/log/apache2/access.log
therefore
Sourcetype = apacheRemember when we configured auth.log?
We literally told Splunk:
[monitor:///var/log/auth.log]
disabled = 0
index = main
sourcetype = linux_secureNotice this line:
sourcetype = linux_secureWe assigned the sourcetype ourselves.
If we added Apache logs, we might configure:
[monitor:///var/log/apache2/access.log]
disabled = 0
index = main
sourcetype = apacheNow Splunk knows:
Source:
/var/log/apache2/access.log
Sourcetype:
apachebecause we told it so.
Think of it like a label
The source is the file:
/var/log/apache2/access.logThe sourcetype is the label attached to the file:
apacheSplunk doesn't magically know the label.
Some sourcetypes are auto-detected, but many are manually assigned.
Quick Quiz
Suppose I configure:
[monitor:///var/log/apache2/access.log]
sourcetype = bananaQuestion:
What would Splunk show?
Source = ?
Sourcetype = ?Take your best guess. This is the question that makes the difference click. π
source = var/log/apache2/access.log]
sourcetype = banana
Host:
ubuntu-server
Source:
/var/log/apache2/access.log
Sourcetype:
apacheTell me:
Which machine generated the event?
Which file generated the event?
What type of log is it?
Answer in full sentences.
If you can answer that without looking at your notes, you've genuinely learned the concept instead of memorizing it. π₯
1. Ubuntu-Server
2. /var/log/apache2/access.log
3. apache
Almost! You got 1 and 2 correct.
1. Which machine generated the event?
ubuntu-serverβ Correct
2. Which file generated the event?
/var/log/apache2/access.logβ Correct
3. What type of log is it?
You answered:
apacheThe example said:
Sourcetype:
apacheSo the answer is:
apacheExample Breakdown
Failed SSH Login
Host:
ubuntu-server
Source:
/var/log/auth.log
Sourcetype:
linux_secureApache Web Request
Host:
ubuntu-server
Source:
/var/log/apache2/access.log
Sourcetype:
apacheCount
Count answers:
How many events matched?Example:
source="/var/log/auth.log"
| stats countPossible Result:
count = 31Meaning:
31 events matched the searchstats count
Basic
| stats countTranslation:
Count all matching eventsBy Host
| stats count by hostTranslation:
Count events per machineExample:
ubuntu-server 31By Source
| stats count by sourceTranslation:
Count events per log fileExample:
/var/log/auth.log 31By Sourcetype
| stats count by sourcetypeTranslation:
Count events per log typeExample:
linux_secure 31top Command
Example
| top sourcetypeTranslation:
Show the most common sourcetypesExample:
linux_secure 31 100%Meaning:
31 events belonged to linux_secureReal Searches Learned Today
Count Auth Events
source="/var/log/auth.log"
| stats countTranslation:
How many auth.log events exist?Count By Host
source="/var/log/auth.log"
| stats count by hostTranslation:
How many auth.log events came from each machine?Count By Source
source="/var/log/auth.log"
| stats count by sourceTranslation:
How many auth.log events came from each log file?Count By Sourcetype
source="/var/log/auth.log"
| stats count by sourcetypeTranslation:
How many auth.log events belong to each log type?Detection Workflow
Today you completed:
Kali
β
SSH Attack
β
Ubuntu auth.log
β
Splunk Ingestion
β
Splunk Search
β
DetectionThis is a real SOC workflow.
SSH Detection Evidence
Generated Attack:
ssh fakeuser@192.168.10.103Evidence Found:
Invalid user fakeuser
Failed password for invalid user fakeuser
Connection closedAttacker:
192.168.10.104Target:
192.168.10.103Concepts To Review Before Next Session
You should be able to explain:
1
What is an Event?Answer:
One log entry2
What is a Host?Answer:
The machine that created the event3
What is a Source?Answer:
The file that generated the event4
What is a Sourcetype?Answer:
The type/category of log5
What does stats count do?Answer:
Counts matching events6
What does by host mean?Answer:
Group results by machine7
What does by source mean?Answer:
Group results by log file8
What does by sourcetype mean?Answer:
Group results by type of log