Splunksplunkfield-extractionregexlookupproduction-ready
Field Extraction and Enrichment
SPL patterns for extracting structured fields from unstructured logs, enriching events with lookup tables, and normalizing data.
title: "Field Extraction and Enrichment" description: "SPL patterns for extracting structured fields from unstructured logs, enriching events with lookup tables, and normalizing data." category: "Splunk" language: "spl" tags: ["splunk", "field-extraction", "regex", "lookup", "production-ready"] createdAt: "2025-04-10" updatedAt: "2025-04-25"
Overview
Patterns for extracting structured fields from unstructured logs using regex, enriching events with external lookup tables (CSV), and normalizing inconsistent field formats across different log sources into a unified schema.
Code
| rex field=_raw "duration=(?<duration_ms>\d+)ms"
| lookup service_owners.csv service_name OUTPUT team, oncall_email
| eval normalized_status=case(status="OK", 200, status="Error", 500)Notes
- Named capture groups in
rexcreate new searchable fields at search time - Use
spathfor JSON field extraction instead of regex (faster and more reliable) - Lookup tables (CSV files) enrich events with metadata not present in logs
cidrmatchidentifies internal vs external traffic without maintaining IP lists- Field normalization with
case()handles inconsistent formats from different services - Consider
REPORTtransforms in props.conf for high-volume extraction at index time