- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Extract multiple fields with one RegEx
Splunkers,
I'm trying to write one regex to extract a bunch of fields from a single event.
Here's an example of one event of some of the fields in one event:
avgtemp 50 hottemp 50 tempalert y tempflag y etc
I've tried using a pipe to separate the field extractions with no luck.
When I run the preview in the Splunk field extractor, I get no results. When I remove every capture group except the first one, it works just fine.
Any advice with the regex would be great.
Thanks
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think I would need some sample data but for the time being what comes before the regex can affect your results.
|regex Event_Sample="1st field|2nd field"
If you still could use an answer to this question just comment on this feed.
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

if your event is like
avgtemp 50 hottemp 50 tempalert y tempflag y etc
you can list each field : try
mysearch
| rex "avgtemp (?<avgtemp>\d+) hottemp (?<hottemp>\d+) tempalert (?<tempalert)\w+) tempflag (?<tempflag>\d+)" "
| table avgtemp hottemp tempalert tempflag
or you can use a field transforms and define the field name dynamically.
see transforms.conf
example on disk on the search-head.
props.conf
[mysourcetype]
TRANSFORMS-myextraction=repeat_regex_space_separator
transforms.conf
[repeat_regex_space_separator]
REGEX = ([a-z])]\s(\d+)
FORMAT = $1::$2
REPEAT_MATCH = true
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

What if this sequence is not in order:
avgtemp 50 hottemp 50 tempalert y tempflag y etc
avgtemp 50 tempalert y tempflag y etc hottemp 50
?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to do this in the field extractor.
SourceSystem\s(?P\w+)(.*?)TargetSystem\s(?P\w+)
Would the (.*?) work?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content


Please provide a good set of example data (anonymized, but valid - only anonymize, don't change anything otherwise) that you also use the 101010
button on to make it be formatted correctly and it doesn't remove any characters) along with your non-working regular expression (again using the 101010
button for formatting). That will help tremendously in helping you.
