<?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: How to do field extraction and event exclusion? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397653#M115416</link>
    <description>&lt;P&gt;I tried the following ,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Raccess" (host="AVOP" OR host="BVOP") date_wday!=saturday AND date_wday !=sunday
 makeresults | eval input=_raw | rex field=_raw "^(?&amp;lt;ips&amp;gt;\S+)\s\|\s(?&amp;lt;protocol&amp;gt;\S+)\s\|\s(?&amp;lt;id&amp;gt;i\S+)\s\|\s([^\|]+\|\s){8}(?&amp;lt;id_no&amp;gt;\S+)" | stats values(id_no)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It gives errors saying &lt;STRONG&gt;Error in 'makeresults' command: This command must be the first command of a search.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jun 2018 14:04:51 GMT</pubDate>
    <dc:creator>zacksoft</dc:creator>
    <dc:date>2018-06-20T14:04:51Z</dc:date>
    <item>
      <title>How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397649#M115412</link>
      <description>&lt;P&gt;Need help with field extractions. Need to extract the fields in bold.&lt;BR /&gt;
Here are two sample events&lt;/P&gt;

&lt;P&gt;Sample1&lt;BR /&gt;
40.156.209.1 | ssh | &lt;STRONG&gt;o*4RAGZLx404x22840423x1&lt;/STRONG&gt; | JG25721 | 2018-06-20 06:44:51,219 | SSH - git-upload-pack '/dga/dgiodbatc.git' | - | 0 | 4 | 1911 | cache:miss, refs, ssh:user:id:126642 | &lt;STRONG&gt;2140&lt;/STRONG&gt; | 1hgs9dp | &lt;/P&gt;

&lt;P&gt;Sample2&lt;BR /&gt;
10.348.20.158,30.158.219.1 | https | &lt;STRONG&gt;i*1N0FIQQx408x22719240x2&lt;/STRONG&gt; | - | 2018-06-20 06:48:08,653 | "GET /rest/api/1.0/repos HTTP/1.1" | "" "Apache-HttpClient/4.5.3 (Java/1.8.0_77)" | - | - | - | - | - | - | &lt;/P&gt;

&lt;P&gt;Post extraction of the first field , check if that extracted field starts with "o" then extract the second bold field (i.e. 2140) and if the extracted first field starts with "i" then ignore that event.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 10:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397649#M115412</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-06-20T10:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397650#M115413</link>
      <description>&lt;P&gt;Maybe something like this as field extraction&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;^(?&amp;lt;ips&amp;gt;\S+)\s\|\s(?&amp;lt;protocol&amp;gt;\S+)\s\|\s(?&amp;lt;id&amp;gt;\S+)\s\|\s([^\|]+\|\s){8}(?&amp;lt;id_no&amp;gt;\S+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the "*" makes it a little cumbersome, but this should work: &lt;CODE&gt;base search | where NOT like(id,"i%")&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Personally, I'd just extract all the fields btw and not use &lt;CODE&gt;([^\|]+\|\s){8}&lt;/CODE&gt; to skip to the number later on, but if you don't need the other fields, well...&lt;/P&gt;

&lt;P&gt;Hth,&lt;BR /&gt;
-Kai.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 12:35:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397650#M115413</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2018-06-20T12:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397651#M115414</link>
      <description>&lt;P&gt;Could you help me form it in a query&lt;BR /&gt;
This is how I am composing&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;sourcetype="Raccess" (host="AVOP" OR host="BVOP") date_wday!=saturday AND date_wday !=sunday&lt;BR /&gt;
| rex "^(?\S+)\s|\s(?\S+)\s|\s(?\S+)\s|\s([^|]+|\s){8}(?\S+)" &lt;BR /&gt;
|  where NOT like(id,"i%")&lt;BR /&gt;
| timechart values(id_no)&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;This doesn't give me any result.&lt;BR /&gt;
Yes, extracting all the fields would also help me a great deal... But we just gotta make sure only to extract the fields from the events if the third field of the event starts with an 'o'  Not 'i'.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:06:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397651#M115414</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T20:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397652#M115415</link>
      <description>&lt;P&gt;Would you mind putting your code into code blocks? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Well, it wasn't meant to be used as rex command, I thought of field extraction on the sourcetype in question, and then doing a search with that. That being said, in my test it works with rex.&lt;/P&gt;

&lt;P&gt;If you insist on not extracting the field on i* (I just discarded those events with the NOT like() clause), you could do that directly in rex as well, eg&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=input "^(?&amp;lt;ips&amp;gt;\S+)\s\|\s(?&amp;lt;protocol&amp;gt;\S+)\s\|\s(?&amp;lt;id&amp;gt;i\S+)\s\|\s([^\|]+\|\s){8}(?&amp;lt;id_no&amp;gt;\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;will only extract when id starts with "i", and then you can lose the "where NOT".&lt;/P&gt;

&lt;P&gt;At least this works when I pipe your example through, like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval input="40.156.209.1 | ssh | i*4RAGZLx404x22840423x1 | JG25721 | 2018-06-20 06:44:51,219 | SSH - git-upload-pack '/dga/dgiodbatc.git' | - | 0 | 4 | 1911 | cache:miss, refs, ssh:user:id:126642 | 2140 | 1hgs9dp |" | rex field=input "^(?&amp;lt;ips&amp;gt;\S+)\s\|\s(?&amp;lt;protocol&amp;gt;\S+)\s\|\s(?&amp;lt;id&amp;gt;i\S+)\s\|\s([^\|]+\|\s){8}(?&amp;lt;id_no&amp;gt;\S+)" | stats values(id_no)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;UL&gt;
&lt;LI&gt;if I change the input on that to id=o*...., you don't get anything, but you get 2140 as is.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 20 Jun 2018 13:22:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397652#M115415</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2018-06-20T13:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397653#M115416</link>
      <description>&lt;P&gt;I tried the following ,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Raccess" (host="AVOP" OR host="BVOP") date_wday!=saturday AND date_wday !=sunday
 makeresults | eval input=_raw | rex field=_raw "^(?&amp;lt;ips&amp;gt;\S+)\s\|\s(?&amp;lt;protocol&amp;gt;\S+)\s\|\s(?&amp;lt;id&amp;gt;i\S+)\s\|\s([^\|]+\|\s){8}(?&amp;lt;id_no&amp;gt;\S+)" | stats values(id_no)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It gives errors saying &lt;STRONG&gt;Error in 'makeresults' command: This command must be the first command of a search.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 14:04:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397653#M115416</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-06-20T14:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397654#M115417</link>
      <description>&lt;P&gt;"makeresults" is what is being used a lot here to generate artificial result sets, since people don't have the same raw data as other people.&lt;/P&gt;

&lt;P&gt;So you could cut and paste my last answer without any additional base search to play around with it. Sorry, I took that for granted.&lt;/P&gt;

&lt;P&gt;So what about &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype="Raccess" (host="AVOP" OR host="BVOP") date_wday!=saturday AND date_wday !=sunday | rex field=_raw "^(?&amp;lt;ips&amp;gt;\S+)\s\|\s(?&amp;lt;protocol&amp;gt;\S+)\s\|\s(?&amp;lt;id&amp;gt;i\S+)\s\|\s([^\|]+\|\s){8}(?&amp;lt;id_no&amp;gt;\S+)" | stats values(id_no)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Doesn't that work? If not, then your raw data doesn't probably exactly match what you posted here, or I may be misunderstanding something. It happens, I am so used to using Splunk in a certain way with certain data sets and questions, that I automatically misunderstand in my own way. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jun 2018 14:13:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397654#M115417</guid>
      <dc:creator>knielsen</dc:creator>
      <dc:date>2018-06-20T14:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to do field extraction and event exclusion?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397655#M115418</link>
      <description>&lt;P&gt;Thank you @knielsen&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jun 2018 13:47:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-do-field-extraction-and-event-exclusion/m-p/397655#M115418</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2018-06-21T13:47:40Z</dc:date>
    </item>
  </channel>
</rss>

