<?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: Can you help me create a search that efficiently filters consecutive events? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391771#M114040</link>
    <description>&lt;P&gt;thanks, I am looking to filter away a pre-known sequence of logs in the search. for example, I know that due to some automation scripts, there will always be a set of logs that looks something like:&lt;/P&gt;

&lt;P&gt;some session ID X | 1 | abc&lt;BR /&gt;
some session ID X | 2 | def&lt;BR /&gt;
some session ID X | 3 | ghi&lt;/P&gt;

&lt;P&gt;I want to filter this sequence of logs away as they are not useful and clog up the report.&lt;BR /&gt;
By the pipes, I was trying to show that its different fields/columns.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Sep 2018 14:06:40 GMT</pubDate>
    <dc:creator>cboonyan</dc:creator>
    <dc:date>2018-09-25T14:06:40Z</dc:date>
    <item>
      <title>Can you help me create a search that efficiently filters consecutive events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391769#M114038</link>
      <description>&lt;P&gt;Some of my logs are generated via automatic jobs and I want to filter them away. What is the best way to filter away a sequence of consecutive events after sorting?&lt;/P&gt;

&lt;P&gt;For example, these are my events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sessionID | logNo | logText
sess1 | 1 | abc
sess1 | 2 | def
sess1 | 3 | ghi
sess2 | 1 | abc
sess2 | 2 | def
sess2 | 3 | ghi
sess3 | 1 | keep
sess3 | 2 | this
sess4 | 1 | abc
sess4 | 2 | def
sess4 | 3 | ghi
sess4 | 4 | something else

base search | sort sessionID, logNo | ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The end result is that I only want to retain sess3 and sess4 events, while filtering  away sess1 and sess2.&lt;BR /&gt;
To explain, I have identified a set of logs that are generated automatically having the same sessionID.&lt;BR /&gt;
This is what I intend to filter away from showing up.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;logNo | logText
1 | abc
2 | def
3 | ghi
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, I do not want to filter away sess4 as it contains as additional logNo4 even though it's logNo 1 to 3 are what I want to filter away previously.&lt;/P&gt;

&lt;P&gt;I have an idea to parse the events into something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sessionID | combined
sess1 | 1 abc 2 def 3 ghi
sess2 | 1 abc 2 def 3 ghi
sess3 | 1 keep 2 this
sess4 | 1 abc 2 def 3 ghi 4 something else
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then use a where combined!="1 abc 2 def 3 ghi" to filter away the automatic generated logs in its entirety.&lt;/P&gt;

&lt;P&gt;The solution has to scale for at least 3..n consecutive events and the combined logText can be rather long to the tune of &amp;gt;1000 characters each.&lt;/P&gt;

&lt;P&gt;If this is a good approach, how can I go about doing it? If not, are there any better and computationally efficient ways to achieve this?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 13:29:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391769#M114038</guid>
      <dc:creator>cboonyan</dc:creator>
      <dc:date>2018-09-25T13:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me create a search that efficiently filters consecutive events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391770#M114039</link>
      <description>&lt;P&gt;I'm not sure it's clear what your end goal is.  About 75% of your objective seems really easy, with something like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup answers.csv
| eval unique_strings = logNo . "-" . logText
| stats values(unique_strings) AS uniques BY sessionID
| eval uniques = mvjoin(uniques, ",")
| dedup uniques
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That gives output&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sessionID       uniques 
sess1   1-abc,2-def,3-ghi
sess3   1-keep,2-this
sess4   1-abc,2-def,3-ghi,4-and_this 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(Of course I obviously substituted a csv lookup of your data, comma separated instead of pipes, instead of calling wherever you get your data from).  &lt;/P&gt;

&lt;P&gt;Anyway, that's easy enough, but ... I'm just not quite sure where you are going.  Sometimes knowing a &lt;EM&gt;why&lt;/EM&gt; can help us get you there or find another solution to the problem.  &lt;/P&gt;

&lt;P&gt;(And I think we can get to what might be your final solution - I'm just not quite sure I understand the why of it yet)&lt;/P&gt;

&lt;P&gt;But, maybe that alone helps?&lt;/P&gt;

&lt;P&gt;-Rich&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 13:59:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391770#M114039</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-09-25T13:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me create a search that efficiently filters consecutive events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391771#M114040</link>
      <description>&lt;P&gt;thanks, I am looking to filter away a pre-known sequence of logs in the search. for example, I know that due to some automation scripts, there will always be a set of logs that looks something like:&lt;/P&gt;

&lt;P&gt;some session ID X | 1 | abc&lt;BR /&gt;
some session ID X | 2 | def&lt;BR /&gt;
some session ID X | 3 | ghi&lt;/P&gt;

&lt;P&gt;I want to filter this sequence of logs away as they are not useful and clog up the report.&lt;BR /&gt;
By the pipes, I was trying to show that its different fields/columns.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 14:06:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391771#M114040</guid>
      <dc:creator>cboonyan</dc:creator>
      <dc:date>2018-09-25T14:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me create a search that efficiently filters consecutive events?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391772#M114041</link>
      <description>&lt;P&gt;Are these records time oriented?  Using streamstats may also be an option (as part of the solution only).&lt;/P&gt;</description>
      <pubDate>Tue, 25 Sep 2018 14:37:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-create-a-search-that-efficiently-filters/m-p/391772#M114041</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-09-25T14:37:42Z</dc:date>
    </item>
  </channel>
</rss>

