Splunk events often come in as raw logs. To make them usable, you need to extract meaningful fields. Splunk provides several ways to do this — both manually and automatically.
rex and erexrex uses regular expressions (regex) to extract custom fields directly in a search.Syntax:
rex field=<field_name> "<regex with named capture group>"
Example:
rex field=_raw "user=(?<username>\w+)"
This extracts a string like user=alice and creates a new field called username with the value alice.
If field is not specified, rex assumes it should extract from _raw.
erex helps you build regex automatically using example values.
Example:
... | erex username examples="alice, bob"
Note: erex is a good starting point for beginners, but rex is more powerful once you're comfortable with regular expressions.
A field alias allows you to treat two different field names as if they are the same. This is useful when different sourcetypes use different field names for the same thing.
Example:
user_id → id
If one sourcetype uses user_id and another uses id, you can create an alias so that both are treated the same in your searches.
This is defined in props.conf (admin-level config).
Calculated fields are automatically created using eval expressions. Unlike inline eval, calculated fields are defined once and automatically added to relevant events.
Example:
eval full_name = first_name . " " . last_name
When you define this as a calculated field, it will always appear in searches where first_name and last_name exist, without you needing to write eval again.
These are configured in props.conf at the app or sourcetype level.
Splunk has two main types of field extractions, depending on when they occur:
This is the most common.
Fields are extracted only when a search is run.
Flexible and easy to modify.
Performance depends on search complexity.
Example:
rex field=_raw "status=(?<status_code>\d+)"
You can change the regex in your search at any time.
Happens when data is ingested into Splunk.
Fields are permanently stored in the index.
Faster during searches because fields are already available.
But it’s irreversible — mistakes cannot be corrected after indexing.
This is usually only done for very high-volume fields where performance is critical (like host, source, sourcetype).
Configured via:
props.conf (specifies the field extraction)
transforms.conf (defines the regex or lookup logic)
Index-time extractions are used carefully, mostly by Splunk admins.
Field transformations allow you to define complex field mappings or lookups and apply them consistently.
These are configured in:
props.conf: Assigns transformations to a sourcetype or source
transforms.conf: Contains the actual logic (regex or lookup definition)
Regex-based field extraction
Automatic field lookup based on IP, user ID, etc.
Lookup mapping fields to other fields (enrichment)
Example: Use a lookup table to match a user_id with a department_name and add that as a field to every event.
To make field management efficient and scalable, follow these best practices:
Every rex, eval, or complex extraction adds processing time.
If you use the same extraction repeatedly, consider turning it into:
A calculated field
A field transformation
fields command to limit field processingIf you only need a few fields, explicitly select them using the fields command:
... | fields user, status, error_code
This reduces:
Memory usage
Search result size
Search execution time
Avoid confusion by creating aliases and calculated fields so that similar concepts are always referred to by the same field name across different sourcetypes.
Use lowercase with underscores (user_name, not UserName)
Avoid spaces in field names
Be consistent across apps and sourcetypes
| Technique | When Used | Editable | Level Required |
|---|---|---|---|
rex in search |
Ad hoc field extraction | Yes | User/Search level |
| Field Alias | Map alternative names | Yes | Admin/App level |
| Calculated Field | Auto-eval expressions | Yes | Admin/App level |
| Search-time Extract | Dynamically during search | Yes | Any user |
| Index-time Extract | Permanent at ingestion | No | Admin only |
| Field Transformation | Regex/lookup-based auto extraction | Yes | Admin level |
props.conf: Direct Regular Expression ExtractionWhile field extractions are commonly done via transforms.conf, Splunk also allows defining search-time extractions directly within props.conf using the EXTRACT- setting.
This method is simpler and used for lightweight extractions, especially when transformation logic is minimal.
Syntax Example:
[my_sourcetype]
EXTRACT-user = user=(?P<username>\w+)
Explanation:
This creates a search-time field called username from the user= pattern.
It works without needing transforms.conf.
The extraction is performed each time a search is run, not during indexing.
It is applied to events tagged with my_sourcetype.
Exam Tip: Questions may try to confuse this with index-time extraction. Remember: EXTRACT- in props.conf always applies at search time, even though it looks like a static config.
eval – Key DistinctionAlthough both calculated fields and inline eval use similar syntax, their behaviors and purpose differ significantly.
evalWritten manually in each search
Temporary — only exists during that search
Requires repetition across dashboards and alerts
Defined once (in props.conf or via the UI)
Automatically evaluated every time relevant data is searched
Does not require re-writing the eval expression
Key Sentence to Remember:
“Unlike inline eval, a calculated field is defined once and does not need to be written into each search.”
Example (calculated field defined in props.conf):
[web_logs]
EVAL-full_name = first_name . " " . last_name
This will ensure full_name is automatically available in all searches for events from web_logs.
Understanding the order in which Splunk applies field extractions is a common advanced exam topic.
Index-time extractions
These occur when data is ingested. Fields are extracted and stored in tsidx files.
Search-time extractions
These occur when a search runs, and can include:
EXTRACT (in props.conf)
Transforms
rex commands
Field aliases and calculated fields
If the same field name is extracted both at index time and search time:
The search-time extraction takes precedence
This ensures that temporary or more specific corrections can override earlier (possibly flawed) indexed data
Practical Implication:
If your index-time extraction mistakenly extracts a partial value, but you define a better search-time extraction, the search-time version wins.
Exam Tip: Watch for questions that test whether field foo will use its indexed or extracted value if both exist.
| Topic | Key Insight |
|---|---|
EXTRACT- in props.conf |
Used for search-time field extractions without transforms.conf |
Calculated Field vs Inline eval |
Calculated field is defined once; inline eval must be written every time |
| Extraction Priority | Search-time overrides index-time for the same field name |
When is rex the right choice for creating a field during a search?
Use rex when you need search-time extraction from raw or existing text and the field is not already available.
rex is ideal for ad hoc extraction, prototyping, or cases where changing upstream extraction rules is not appropriate. It is especially common when users need one targeted field for a report or dashboard. The tradeoff is cost: regex processing can be expensive if used broadly or written inefficiently. On the exam, the clue for rex is usually “extract a field during the search” or “use a regex expression directly in SPL.” If the field already exists reliably, using rex again may add unnecessary overhead.
Demand Score: 55
Exam Relevance Score: 90
Why does regex performance matter in Splunk search-time field extraction?
Because inefficient regex can consume significant search resources and slow down user-facing searches or dashboards.
Search-time extraction happens while results are being prepared, so overly broad patterns, heavy backtracking, or extracting more than necessary can hurt responsiveness. Practitioners often notice the problem only after searches scale up to larger time ranges or more users. On the exam, regex performance is less about memorizing syntax and more about choosing focused patterns and avoiding unnecessary extraction. If the scenario mentions sluggish searches caused by field extraction, the likely best practice is tightening the regex or extracting less.
Demand Score: 54
Exam Relevance Score: 87
What is the difference between erex and rex from an exam perspective?
erex helps generate extraction expressions from examples, while rex applies a regex directly.
The distinction is conceptual. rex assumes you already know the pattern and want to use it in the search. erex is more assistive and example-driven, helping derive field extraction logic from sample values. On the exam, if the prompt says “provide examples and have Splunk infer the extraction,” that points toward erex. If it says “apply this regular expression,” that points to rex. A common mistake is treating them as interchangeable when their workflow purpose is different.
Demand Score: 43
Exam Relevance Score: 84