So I am relatively new to extracting fields in Splunk, but I have some knowledge of regex, and I'm attempting to apply it in Splunk.
I have a pattern I am attempting to extract and put into a field. The pattern looks like this:
USER@TEST
I am using this expression to match the pattern:
(\w+@\w+)
I would like to extract this into a field called "user_domain", and I'm having some difficulty renaming (\w+@\w+)
as "user_domain
".
PS... this forum doesn't show forward slashes, however they are there. 😃
What ways did you try? You could make use of the rex
command, like this:
... | rex "(?<user_domain>\w+@\w+)"
Or you could make this kind of extraction permanent by using the interactive field extractor (http://docs.splunk.com/Documentation/Splunk/latest/User/InteractiveFieldExtractionExample ).
By curiosity, are you trying to extract apache logs or IIS logs ?
Existing sourcetypes provide automatic extraction :
It does happen automagically, but you can make any sourcetype extract the same fields with the transform. start taking a look at props.conf, and transforms.conf for general iis field extractions.
Negative yannK, These are proprietary log messages that I'm attempting to scrub.
But to make sure I understand you correctly, because we do have apache and iis logs here as well, if I name my sourcetype "access_combined" and send my iss / apache logs there, Splunk will extract a set of fields auto-magically?
yes, some sourcetypes are defined and provide automatic field extractions. look for : syslog, access_combined and apache_errors ...
see http://docs.splunk.com/Documentation/Splunk/4.3.2/Data/Listofpretrainedsourcetypes
What ways did you try? You could make use of the rex
command, like this:
... | rex "(?<user_domain>\w+@\w+)"
Or you could make this kind of extraction permanent by using the interactive field extractor (http://docs.splunk.com/Documentation/Splunk/latest/User/InteractiveFieldExtractionExample ).
Actually... I didn't try that at all.
<--- Shamed
| rex "(?
that worked splendidly, thank you!
I did try the interactive extractor though, but it won't extract everything I needed it to.