<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: help with field extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275340#M83057</link>
    <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search | rex  "SessionId:\s+\d+-\s+User\s+(?&amp;lt;User&amp;gt;\S+)\s+-\s+Client_ip"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Feb 2016 17:48:05 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2016-02-08T17:48:05Z</dc:date>
    <item>
      <title>help with field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275339#M83056</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a field extraction that I'm hoping someone can help me with.&lt;/P&gt;

&lt;P&gt;Here's the example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-08T12:17:34.219722-05:00 myhost  02/08/2016:12:16:12  mhost 0-PPE-0 : SSLVPN LOGIN 6457080 0 : Context z123456@1.2.3.4 - SessionId: 10109- User z123456 - Client_ip 1.2.3.4
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need to extract the second z123456 field, but I also want to put the SessionId and Client_ip as validators for part of the regex.  &lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 17:26:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275339#M83056</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-02-08T17:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: help with field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275340#M83057</link>
      <description>&lt;P&gt;Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search | rex  "SessionId:\s+\d+-\s+User\s+(?&amp;lt;User&amp;gt;\S+)\s+-\s+Client_ip"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2016 17:48:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275340#M83057</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-08T17:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: help with field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275341#M83058</link>
      <description>&lt;P&gt;Sure, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex "Context\s+(?&amp;lt;context&amp;gt;[^\s]+)\s+-\s+SessionId:\s+(?&amp;lt;SessionID&amp;gt;\d+)\s?-\s+User\s+(?&amp;lt;User&amp;gt;[^\s]+)\s+-\s+Client_ip\s+(?&amp;lt;client_ip&amp;gt;[^\s]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try that as your rex.  I don't know if the lack of a space beween the session id 10109 and he dash after it is legit or a mistake, so I put that "space" as optional (hence that one is \s? instead of \s+ as the others are)&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 17:48:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275341#M83058</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-02-08T17:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: help with field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275342#M83059</link>
      <description>&lt;P&gt;Thanks. This works great.  How would I plug this into the field extractor?  &lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2016 18:24:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275342#M83059</guid>
      <dc:creator>a212830</dc:creator>
      <dc:date>2016-02-08T18:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: help with field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275343#M83060</link>
      <description>&lt;P&gt;I suspect the real question is "How do I make this 'automatic' and have it work on all appropriate events so I have fields to use in my reports?"  Is that right?&lt;/P&gt;

&lt;P&gt;The field extractor is one way to have built the rex above.  I did it manually, so there's no real need for the field extractor itself.  &lt;/P&gt;

&lt;P&gt;To make it run automatically, the field extractor puts the entries that are created in &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1/Admin/propsconf" target="_blank"&gt;props.conf&lt;/A&gt; as an EXTRACT line against your sourcetype (note a).  You can do the same by editing your apps' $splunkhome/etc/-appname-/local/props.conf (making it if required) or using the $splunkhome/etc/system/local/props.conf one if you aren't creating or in an app (note b). &lt;/P&gt;

&lt;P&gt;Your entry will be something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[mysourcetype]
EXTRACT-SSLVPN_info = Context\s+(?&amp;lt;context&amp;gt;[^\s]+)\s+-\s+SessionId:\s+(?&amp;lt;SessionID&amp;gt;\d+)\s?-\s+User\s+(?&amp;lt;User&amp;gt;[^\s]+)\s+-\s+Client_ip\s+(?&amp;lt;client_ip&amp;gt;[^\s]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where "mysourcetype" is the sourcetype of this data.  You will need to restart splunk or at least on a blank search do &lt;CODE&gt;| extract reload=t&lt;/CODE&gt; (I promise, beginning pipe won't break anything!).&lt;/P&gt;

&lt;P&gt;After that, those extractions should show up in your event searches that return the data that should be extracted.  &lt;/P&gt;

&lt;P&gt;Please post back if you have difficulties!&lt;/P&gt;

&lt;P&gt;Note, the field extractor is very useful and I use it from time to time myself, but it isn't always the best regex-writer.  I usually prefer creating my own regexes because, even as bad as they are, they're better (note c) than the ones the field extractor usually writes.   Besides, regex is FUN!&lt;/P&gt;

&lt;P&gt;Oh, lastly, if you DO want to use the field extractor, I think you can tell it you want the "regex" variety of extractions (it's one of the wizard's options early on), then select a row to work on, select the piece you want extracted (let's say in this case it's the client_ip), then there's a button to "view regex" or something - show that.  Once you see that, paste in your own regex which in the case of client IP would be... &lt;CODE&gt;Client_ip\s+(?[^\s]+&lt;/CODE&gt; then save it.  I've used a process liek that before, but there have been changes to the wizard in the last few versions so you might have to make some adjustments to my instructions.&lt;/P&gt;

&lt;P&gt;a) I may have lied, I don't know how the field extractor does it though I'm sure it's a variant of what I described.&lt;BR /&gt;
b) I recommend an app, but hey, as long as you aren't trying to stick this in the default folder I'm OK with it.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
c) For suitably loose values of "better", but often more generic yet more precise.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:41:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275343#M83060</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2020-09-29T08:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: help with field extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275344#M83061</link>
      <description>&lt;P&gt;Remember to do like @rich7177 mentioned and DO NOT include the quotes when pasting into Field Extractor or manually adding a new extraction (through UI or conf file). That tends to nail everyone.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Feb 2016 22:21:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/help-with-field-extraction/m-p/275344#M83061</guid>
      <dc:creator>sloshburch</dc:creator>
      <dc:date>2016-02-12T22:21:38Z</dc:date>
    </item>
  </channel>
</rss>

