<?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: Time difference where values are at random place in a file. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315102#M94344</link>
    <description>&lt;P&gt;hello there, &lt;BR /&gt;
do you mean 30 seconds?&lt;BR /&gt;
how would you know your first event:  &lt;CODE&gt;22/7/2017 07:05:00 ............. ...........................................XYZ....&lt;/CODE&gt; is not part of an older chain of XYZ?&lt;BR /&gt;
how do you determine the time span? &lt;BR /&gt;
i mean you can basicly search for: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = blah XYZ | stats earliest(_time) as start, latest(_time) as stop  
| eval duration = stop-start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;duration here in seconds is the gap in time between these events&lt;/P&gt;</description>
    <pubDate>Tue, 23 May 2017 13:38:06 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2017-05-23T13:38:06Z</dc:date>
    <item>
      <title>Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315101#M94343</link>
      <description>&lt;P&gt;Hi All, &lt;/P&gt;

&lt;P&gt;I need to search for time taken since a value popped up in the logs. The problem here is that this value is at random places in the logs. &lt;/P&gt;

&lt;P&gt;22/7/2017 07:05:00   ............. ...........................................XYZ....&lt;BR /&gt;
22/7/2017 07:05:10   ............. ...........................XYZ....................&lt;BR /&gt;
22/7/2017 07:05:20   ............. ...........................XYZ....................&lt;BR /&gt;
22/7/2017 07:05:30   ............. ....................XYZ............................&lt;/P&gt;

&lt;P&gt;So could anybody please suggest how to calculate the time till when these values were present? For instance in this example we need to search for value 'xyz' and this should give me 30 mins. &lt;/P&gt;

&lt;P&gt;Appreciate your help. &lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Arjit.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 12:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315101#M94343</guid>
      <dc:creator>arjitgoswami</dc:creator>
      <dc:date>2017-05-23T12:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315102#M94344</link>
      <description>&lt;P&gt;hello there, &lt;BR /&gt;
do you mean 30 seconds?&lt;BR /&gt;
how would you know your first event:  &lt;CODE&gt;22/7/2017 07:05:00 ............. ...........................................XYZ....&lt;/CODE&gt; is not part of an older chain of XYZ?&lt;BR /&gt;
how do you determine the time span? &lt;BR /&gt;
i mean you can basicly search for: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index = blah XYZ | stats earliest(_time) as start, latest(_time) as stop  
| eval duration = stop-start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;duration here in seconds is the gap in time between these events&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 13:38:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315102#M94344</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-05-23T13:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315103#M94345</link>
      <description>&lt;P&gt;Thanks Adonio!  The issue is when we need to create a table for various such names in the logs. &lt;/P&gt;

&lt;P&gt;Just to elaborate the situation here, we have a web application log and we need to see time taken by each Quote ID created. so the logs are something like this : &lt;/P&gt;

&lt;P&gt;22/7/2017 07:05:00 ............. ...........................................XYZ....&lt;BR /&gt;
22/7/2017 07:05:10 ............. ...........................XYZ....................&lt;BR /&gt;
22/7/2017 07:05:20 ............. ...........................XYZ....................&lt;BR /&gt;
22/7/2017 07:05:30 ............. ....................XYZ............................&lt;BR /&gt;
22/7/2017 07:05:40 ............. ...........................................ABC....&lt;BR /&gt;
22/7/2017 07:05:50 ............. ...........................ABC...................&lt;BR /&gt;
22/7/2017 07:06:00 ............. ...........................ABC....................&lt;/P&gt;

&lt;P&gt;and I need output in a table like : &lt;/P&gt;

&lt;P&gt;Quote ID            Time Taken &lt;BR /&gt;
XYZ                      30 Sec&lt;BR /&gt;
ABC                      20 Sec &lt;/P&gt;

&lt;P&gt;If I would have had Quote ID in a particular position or in field called QuoteID, I would have used regular expression and my query would have been  : &lt;/P&gt;

&lt;P&gt;sourcetype=blah  QuoteID | stats earliest(_time) as start, latest(_time) as stop by QuoteID|&lt;BR /&gt;
2. | eval duration = stop-start|&lt;BR /&gt;
3. |table duration QuoteID &lt;/P&gt;

&lt;P&gt;But now these values are scattered one. Could you please advise what can be done here? &lt;/P&gt;

&lt;P&gt;Thanks for your help. &lt;/P&gt;

&lt;P&gt;Kind regards,&lt;BR /&gt;
Arjit. &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:14:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315103#M94345</guid>
      <dc:creator>arjitgoswami</dc:creator>
      <dc:date>2020-09-29T14:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315104#M94346</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your Base Search Here
| eval QuoteID = "XYZ"
| streamstats count(eval(NOT match(_raw, QuoteID))) AS sessionID
| eval sessionID = if(match(_raw, QuoteID), sessionID, null())
| stats range(_time) AS TimeTaken BY sessionID
| table QuoteID TimeTaken
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can do this for a series of &lt;CODE&gt;QuoteID&lt;/CODE&gt; values by extending with &lt;CODE&gt;map&lt;/CODE&gt;.  This checks only for sequential events (without gaps).&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 14:40:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315104#M94346</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-23T14:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315105#M94347</link>
      <description>&lt;P&gt;thanks for elaborating on your question, look at @woodcock advice / answer below&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:20:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315105#M94347</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-05-23T15:20:22Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315106#M94348</link>
      <description>&lt;P&gt;For a group of pre-known &lt;CODE&gt;QuoteID&lt;/CODE&gt; values, you can do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval QuoteID="ABC,XYZ,etc" 
| makemv delim="," QuoteID
| map search="index=YourIndexHere sourcetype=YourSourcetypeHere *$QuoteID$*
    | stats count range(_time) AS TimeTaken 
    | eval QuoteID=\"$QuoteID$\""
| table QuoteID TimeTaken
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is limited by default to 10 values of &lt;CODE&gt;QuoteID&lt;/CODE&gt; but that can be extended.&lt;/P&gt;</description>
      <pubDate>Tue, 23 May 2017 15:43:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315106#M94348</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-23T15:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315107#M94349</link>
      <description>&lt;P&gt;Thanks Woodcock and adonio for your response. But query "For a group of pre-known QuoteID values" is not giving my any results. It looks like map function itself is not working for my splunk. Could you please help? &lt;/P&gt;

&lt;P&gt;Thanks and regards,&lt;BR /&gt;
Arjit Goswami&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2017 04:06:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315107#M94349</guid>
      <dc:creator>arjitgoswami</dc:creator>
      <dc:date>2017-05-24T04:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315108#M94350</link>
      <description>&lt;P&gt;@woodcock @adonio   Hi Woodcock &amp;amp; Adonio, Just a gentle remainder on this. I gave all my quotes in QuoteID (2 of them for testing)  and found that given map query is not working. It looks like some issue with map query. Could you please help ?&lt;/P&gt;

&lt;P&gt;| makeresults &lt;BR /&gt;
1. | eval QuoteID="ABC,XYZ,etc" &lt;BR /&gt;
2. | makemv delim="," QuoteID&lt;BR /&gt;
3. | map search="index=YourIndexHere sourcetype=YourSourcetypeHere &lt;EM&gt;$QuoteID$&lt;/EM&gt;&lt;BR /&gt;
4.     | stats count range(_time) AS TimeTaken &lt;BR /&gt;
5.     | eval QuoteID=\"$QuoteID$\""&lt;BR /&gt;
6. | table QuoteID TimeTaken&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Arjit&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 06:09:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315108#M94350</guid>
      <dc:creator>arjitgoswami</dc:creator>
      <dc:date>2017-05-25T06:09:28Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315109#M94351</link>
      <description>&lt;P&gt;What is your base search (The part that begins with &lt;CODE&gt;index=&lt;/CODE&gt; );  the one that works for just one value and does not use &lt;CODE&gt;map&lt;/CODE&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 19:42:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315109#M94351</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-05-25T19:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Time difference where values are at random place in a file.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315110#M94352</link>
      <description>&lt;P&gt;@woodcock : Hi Woodcock | Acknowledging your response here. Sorry was travelling so couldn't respond you yesterday. I am not sure whether my understanding is correct or not, but based on @niketnilay  response on one other query, I tried to amend the given query and it started working fine. What I have done is that I have added count function and I have added one more "Search' command (based on map documentation) to our map query. &lt;/P&gt;

&lt;P&gt;Please find the updated query below:&lt;/P&gt;

&lt;P&gt;|makeresults&lt;BR /&gt;
|eval QuoteID = "QI-12345,QI-67859,QI-23456,QI-57689,QI-24798"&lt;BR /&gt;
|makemv delim="," QuoteID&lt;BR /&gt;
|stats count by QuoteID&lt;BR /&gt;
|map search="search sourcetype=\"Pega17052017n\" $QuoteID$&lt;BR /&gt;
|stats count range(_time) AS TimeTaken &lt;BR /&gt;
|eval QuoteID=\"$QuoteID$\""&lt;BR /&gt;
|table QuoteID TimeTaken&lt;/P&gt;

&lt;P&gt;I somehow feel that Stats(values) and table functions in base search  doesn't work with Map command. Only count function in base search is sending single-valued result to map command. &lt;/P&gt;

&lt;P&gt;Thanks a lot for your help. Much appreciated !!!&lt;/P&gt;

&lt;P&gt;Kind regards,&lt;BR /&gt;
Arjit Goswami&lt;/P&gt;</description>
      <pubDate>Fri, 26 May 2017 08:22:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Time-difference-where-values-are-at-random-place-in-a-file/m-p/315110#M94352</guid>
      <dc:creator>arjitgoswami</dc:creator>
      <dc:date>2017-05-26T08:22:49Z</dc:date>
    </item>
  </channel>
</rss>

