<?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 edit my search to avoid overlapping events from occurring in timeline? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243715#M72537</link>
    <description>&lt;P&gt;You basically had it, I think.  I tweaked a few tiny typos and optimizations but it is essentially your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MY BASE SEARCH
| eval StartTime = if(LogType = "START", _time, null())
| eval EndTime = if(LogType = "END", _time, null())
| stats latest(StartTime) AS StartTime latest(EndTime) AS EndTime latest(Result) AS Result BY host process id
| eval EndTime = if(isnull(EndTime), now(), EndTime)
| eval Status = if(isnull(Result), "GOING", Result)
| eval duration = (EndTime-StartTime) * 1000
| search duration &amp;gt;= 0
| table StartTime process Status duration
| sort 0 StartTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Jan 2017 20:51:22 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-01-20T20:51:22Z</dc:date>
    <item>
      <title>How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243706#M72528</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;

&lt;P&gt;I have something which sends me the START and the STOP of some processes.&lt;/P&gt;

&lt;P&gt;I have this search that creates a timeline chart and, if in some processes we have just the START event, assumes that this process must be GOING so it attributes to that process endtime = now (just for the sake of drawing the bar) .&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MY BASE SEARCH
| eval StartTime = if(LogType = "START", _time, null)
| eval EndTime = if(LogType = "END", _time, null)
| stats Latest(StartTime) as StartTime Latest(EndTime) as EndTime Latest(Result) as Result by process id
| eval EndTime = if(isnull(EndTime), now(), EndTime)
| eval Status = if(isnull(Result), "GOING", Result)
| eval duration = (EndTime-StartTime) * 1000
| where (duration != "" OR duration &amp;gt;= 0) 
| table StartTime process Status duration
| sort StartTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyway sometimes this process has been killed and does not send the STOP event.&lt;BR /&gt;
The consequence of this is that a process that has been killed continues to draw this bar and if the same process started again, we have overlapping, like in the image:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2345i1FFBDDCD630D5683/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;What I would like to do is to exclude those instance of the process which have just a start without having an end but only if another instance of the process is already started.&lt;BR /&gt;
(Instances of the process are identified in the search by the field "id")&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Example: &lt;BR /&gt;
Event1 -&amp;gt; processA   id1   Start &lt;BR /&gt;
Event2 -&amp;gt; processA   id2   Start &lt;BR /&gt;
Event3 -&amp;gt; processA   id2   end &lt;BR /&gt;
In the previous example, with those events a chart with overlapping (like the image)  would come out.&lt;BR /&gt;
So I would like the search to exclude the First start because there is a second start and no end, which means that the process was killed.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I hope I was clear in my explanation.&lt;BR /&gt;
Please don't hesitate to ask me any further details.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 14:21:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243706#M72528</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-19T14:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243707#M72529</link>
      <description>&lt;P&gt;Hi andreafebbo, &lt;/P&gt;

&lt;P&gt;Seems the transaction command is a very good candidate for your use case. Please try the following example search, assuming processId is the name of the field based on which to pair up your events: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction processId startswith="Start" endswith="End" maxevents=2 | where duration &amp;gt; 0 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For detailed information about the transaction command, please refer to documentation: &lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.1/SearchReference/Transaction"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.1/SearchReference/Transaction&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Hope this helps. Thanks!&lt;BR /&gt;
Hunter&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:17:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243707#M72529</guid>
      <dc:creator>hunters_splunk</dc:creator>
      <dc:date>2017-01-19T15:17:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243708#M72530</link>
      <description>&lt;P&gt;What is the timerange for which you run this query??&lt;BR /&gt;
Could you also provide your base search to under the conditions to identify START AND STOP events.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:57:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243708#M72530</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-19T15:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243709#M72531</link>
      <description>&lt;P&gt;I read the documentation and I think it might help me but is not easy to understand deeply how it works.&lt;BR /&gt;
Could you please try to integrate it in my code so I can understand it better?&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:58:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243709#M72531</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-19T15:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243710#M72532</link>
      <description>&lt;P&gt;the base query only contains an index and a source.&lt;BR /&gt;
The events are jsons with fisically written, between the other things, "START" or "END".&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:03:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243710#M72532</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-19T16:03:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243711#M72533</link>
      <description>&lt;P&gt;Time range??? This is important as if it's a daily process, and time range is 2 you'll have 2 instance of that process running. &lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:07:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243711#M72533</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-19T16:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243712#M72534</link>
      <description>&lt;P&gt;Its possible to have 2 instances running in the same day but never together, so if there is overlapping the fist one is been killed.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:14:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243712#M72534</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-19T16:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243713#M72535</link>
      <description>&lt;P&gt;Give this a try. It works best if you don't have too much data to be processed. It's basically taking both type of events separately. Doing so you're able to dedup on START event of a process to keep the last start. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=yourindex sourcetype=yoursourcetype logType="START"
| dedup process | eval StartTime=_time
| append[search index=yourindex sourcetype=yoursourcetype logType="END" | eval EndTime=_time]
| sort 0 -_time
| stats Latest(StartTime) as StartTime Latest(EndTime) as EndTime Latest(Result) as Result by process id
 | eval EndTime = if(isnull(EndTime), now(), EndTime)
 | eval Status = if(isnull(Result), "GOING", Result)
 | eval duration = (EndTime-StartTime) * 1000
 | where (duration != "" OR duration &amp;gt;= 0) 
 | table StartTime process Status duration
 | sort StartTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2017 16:32:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243713#M72535</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-19T16:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243714#M72536</link>
      <description>&lt;P&gt;Does not work, it keeps overlapping.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2017 10:20:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243714#M72536</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-20T10:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243715#M72537</link>
      <description>&lt;P&gt;You basically had it, I think.  I tweaked a few tiny typos and optimizations but it is essentially your search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;MY BASE SEARCH
| eval StartTime = if(LogType = "START", _time, null())
| eval EndTime = if(LogType = "END", _time, null())
| stats latest(StartTime) AS StartTime latest(EndTime) AS EndTime latest(Result) AS Result BY host process id
| eval EndTime = if(isnull(EndTime), now(), EndTime)
| eval Status = if(isnull(Result), "GOING", Result)
| eval duration = (EndTime-StartTime) * 1000
| search duration &amp;gt;= 0
| table StartTime process Status duration
| sort 0 StartTime
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Jan 2017 20:51:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243715#M72537</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-01-20T20:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243716#M72538</link>
      <description>&lt;P&gt;It still creates overlapping &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 09:20:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243716#M72538</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-24T09:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243717#M72539</link>
      <description>&lt;P&gt;What is the difference between  &lt;CODE&gt;| search duration &amp;gt;= 0&lt;/CODE&gt; and &lt;CODE&gt;|where duration &amp;gt;= 0&lt;/CODE&gt;?&lt;/P&gt;

&lt;P&gt;What is the difference between  &lt;CODE&gt;| sort 0 StartTime&lt;/CODE&gt; and &lt;CODE&gt;| sort StartTime&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:28:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243717#M72539</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-24T11:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243718#M72540</link>
      <description>&lt;P&gt;I found the solution myself.&lt;BR /&gt;
This is the code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; MY BASE SEARCH
| eval StartTime = if(LogType = "START", _time, null)
| eval EndTime = if(LogType = "END", _time, null)
| stats Latest(StartTime) as StartTime Latest(EndTime) as EndTime Latest(Result) as Result by precess id
| join type=left precess [search
  MY BASE SEARCH LogType ="START"
  | stats latest(_time) AS LatestStartTime by precess]
| eval EndTime = if(isnull(EndTime), if(StartTime = LatestStartTime, now(), null() ), EndTime)
| eval Status = if(isnull(Result), "GOING", Result)
| eval duration = (EndTime-StartTime) * 1000 
| where duration &amp;gt;= 0
| table StartTime precess Status duration
| sort StartTime
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks to all the people who answered! &lt;BR /&gt;
:)&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 11:33:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243718#M72540</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-24T11:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243719#M72541</link>
      <description>&lt;P&gt;Best practices: I use &lt;CODE&gt;where&lt;/CODE&gt; when there is a field name on the RHS and &lt;CODE&gt;seaerch&lt;/CODE&gt; when there is a literal.  You should get in the habit of using &lt;CODE&gt;sort 0&lt;/CODE&gt; always; otherwise it is limited to 1000 results!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 14:02:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243719#M72541</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-01-24T14:02:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243720#M72542</link>
      <description>&lt;P&gt;What is RHS and what is literal?&lt;BR /&gt;
So 0 menas no limit in the sort?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:28:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243720#M72542</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-24T15:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243721#M72543</link>
      <description>&lt;P&gt;RHS is Right-Hand-Side.  Use &lt;CODE&gt;where&lt;/CODE&gt; if there is a field name on both sides of the comparison operator; Use &lt;CODE&gt;search&lt;/CODE&gt; if there is a field name on the LHS and a non-field-name (a &lt;CODE&gt;literal&lt;/CODE&gt; value) on the RHS.  For &lt;CODE&gt;sort&lt;/CODE&gt; using &lt;CODE&gt;sort 0&lt;/CODE&gt; means unlimited.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243721#M72543</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-01-24T15:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243722#M72544</link>
      <description>&lt;P&gt;And using search instead of where in that case enhance the performance? &lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:38:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243722#M72544</guid>
      <dc:creator>andreafebbo</dc:creator>
      <dc:date>2017-01-24T15:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to avoid overlapping events from occurring in timeline?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243723#M72545</link>
      <description>&lt;P&gt;No, this is for clarity and to avoid bugs.  If you see &lt;EM&gt;my&lt;/EM&gt; code using a single &lt;CODE&gt;search&lt;/CODE&gt; test you know that the RHS is a literal and if you see &lt;CODE&gt;where&lt;/CODE&gt;, you know that I am trying to have the RHS be a field name.  The problem is sometimes a RHS thing (if it is written ambiguously) is intended to be a field name but that field name doesn't exists, and in such cases it will be treated as a literal.  This fallback can cause unintended results.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:51:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-avoid-overlapping-events-from-occurring/m-p/243723#M72545</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-01-24T15:51:05Z</dc:date>
    </item>
  </channel>
</rss>

