Splunk rex command field collision and precedence
0 reputation · 27 Feb 2026, 02:51 UTC
0 reputation · 27 Feb 2026, 02:51 UTC
The rex command in Splunk allows for inline regular expression extractions to create transient fields during search execution. When a named capture group in a rex statement matches a field name that already exists—either as an index-time extraction or a persisted props.conf configuration—the system must resolve the conflict.
There is uncertainty regarding the precedence of these values when the rex command is placed at different stages of the search pipeline relative to other transforming commands.
rex command overwrite the existing field value for the remainder of the pipeline?30275 reputation · 27 Feb 2026, 14:51 UTC
Yes, the rex command overwrites the existing field value for the remainder of the search pipeline. If a named capture group in a rex statement matches a field name that already exists—whether it was created via index-time extraction, props.conf, or a previous command—the rex command replaces the original value with the new match.
The original field value is not preserved in a hidden state; it is permanently replaced in the result set for that specific search execution. Once the overwrite occurs, subsequent commands in the pipeline will only see the value produced by the rex command.
Splunk follows a "last-writer-wins" logic within the search pipeline. The precedence is determined by the order of operations:
rex command in the search string takes precedence over fields extracted via props.conf or fields.conf.rex commands target the same field name, the most recent command in the pipeline determines the final value.rex command contains multiple capture groups with the same name, the last successful match in the event string typically determines the field value.To verify this behavior in your environment (assuming Splunk Enterprise or Cloud), execute the following sequence:
user).index=your_index | table user.rex command to overwrite that field: index=your_index | rex field=_raw "(?<user>OVERWRITTEN)" | table user.user field now displays "OVERWRITTEN" and the original value is no longer accessible.Avoid using rex to overwrite system-protected fields such as _time, host, or source. Overwriting these can break time-based visualizations, bucketing, and index-level filtering.
Diagnostic Detail Required: Are you attempting to overwrite a field that is being used as a primary key for a stats or transaction command later in your pipeline? This would change the recommendation from a simple rex to using eval with a renamed temporary field to preserve the original identity.
Use comments to ask for clarification. Post a solution as an answer.
2,870 reputation · 27 Feb 2026, 12:20 UTC
When the existing field is multivalue, a rex that matches the same name replaces the entire multivalue with the new value (or a new multivalue if max_match>0 is set). The original values are not retained in a hidden multivalue; they are lost for the rest of the pipeline unless you preserve them earlier with rename or eval.