โญ Day 14 โ€“ Log Enrichment, Field Extraction & Metadata

Today students learn how to transform raw logs โ†’ structured data โ†’ security meaning in Splunk.

This is VERY important because:

  • SIEM alerts depend on correct fields
  • Threat hunting depends on good field extraction
  • Dashboards depend on structured data
  • MITRE mapping depends on knowing what each field means

๐Ÿง  1. What Is Log Enrichment? (Simple Explanation)

Log Enrichment = adding extra security context to raw logs.

Before enrichment:

IP=192.168.1.50

After enrichment:

IP=192.168.1.50
GeoLocation=India
Reputation=Malicious
User=tom
DeviceType=Windows10

This makes detection and hunting much easier.


๐Ÿ”ฅ 2. Why Field Extraction Matters?

Field Extraction = splitting raw logs into readable fields.

Example raw log:

Failed password for root from 10.0.0.5 port 4588

Splunk extracts:

  • user = root
  • src_ip = 10.0.0.5
  • port = 4588
  • action = failed password

This allows queries like:

stats count by src_ip


๐Ÿงฑ 3. Three Types of Fields Every SOC Analyst Must Know

A. Source

Where logs came from.
Examples:

  • WinEventLog:Security
  • /var/log/auth.log
  • firewall logs

B. Sourcetype

What type of log it is.
Examples:

  • WinEventLog:System
  • linux_secure
  • Sysmon

C. Fields

Actual extracted data:

  • user
  • IP
  • port
  • status
  • command
  • EventCode

Understanding these transforms raw logs into security detection.


๐Ÿ” 4. Splunk Tools for Field Extraction

โœ” Field Extractor (UI tool)

Go to:

Settings โ†’ Fields โ†’ Field Extractions

Upload sample logs โ†’ highlight โ†’ Splunk generates regex.


โœ” Field Discovery

In search bar:

index=*

Then click on Fields (left side)
โ†’ Shows auto-detected fields.


โœ” Rex Command

Manual extraction:

| rex "Failed password for (?<user>\w+) from (?<src_ip>\d+\.\d+\.\d+\.\d+)"

This creates user and src_ip fields.


โš™๏ธ 5. Sample Field Extraction for Linux Logs

Raw log:

Failed password for root from 10.0.0.5 port 4588

Splunk rex:

| rex "Failed password for (?<user>\w+) from (?<src_ip>\S+) port (?<port>\d+)"

Now you can run:

stats count by src_ip


โš™๏ธ 6. Sample Field Extraction for Windows Logs

Windows logs already have fields, such as:

  • Account_Name
  • Workstation_Name
  • Logon_Type
  • IpAddress

But you can extract extra fields.

Example:

| rex "Account Name:\s+(?<account>\S+)"


๐Ÿงฉ 7. Log Enrichment Techniques

โœ” Add GeoIP info

| iplocation IpAddress

Adds:

  • City
  • Country
  • Region
  • Latitude/Longitude

โœ” Add threat intel reputation

If you have threat feeds:

| lookup bad_ips ip OUTPUT reputation

โœ” Add device type

| lookup device_inventory host OUTPUT device_type

Useful for:

  • identifying servers
  • identifying critical systems

๐Ÿ›  8. Hands-On Lab (Day 14)

Task 1 โ€“ Extract Linux fields

index=* "Failed password"
| rex "Failed password for (?<user>\w+) from (?<ip>\S+)"
| stats count by user, ip


Task 2 โ€“ Extract Windows fields manually

index=* EventCode=4624
| rex "Logon Type:\s+(?<logtype>\d+)"
| stats count by logtype


Task 3 โ€“ Add GeoIP enrichment

index=* IpAddress=* 
| iplocation IpAddress
| table IpAddress Country City


Task 4 โ€“ Create enriched dashboard panel

Panel shows:

  • IP
  • Country
  • City
  • Count
index=* IpAddress=*
| iplocation IpAddress
| stats count by IpAddress, Country, City


Task 5 โ€“ Extract suspicious PowerShell commands

index=* powershell "EncodedCommand"
| rex "CommandLine:\s+(?<cmd>.+)"
| table _time user cmd


๐ŸŽค Trainer Script

Say this:

โ€œField extraction converts raw logs into intelligence.
Enrichment adds context โ€” country, device type, risk.
A SOC analyst must understand fields to build detections and dashboards.โ€


๐Ÿ“ Homework (Day 14)

Students must extract:

  • IP
  • User
  • Port
  • Action

From one log of their choice, AND:

  • Write MITRE technique
  • Write one enriched dashboard query

Leave a comment

Recent posts

Quote of the week

in learning you will teach and in teaching you will learn

~ Phil Collins
Design a site like this with WordPress.com
Get started