<?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: EVAL Total Duration in Minutes Across 2 Indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465951#M191776</link>
    <description>&lt;P&gt;Took a bit of fudging with but got the desired outcome. Thanks very much&lt;/P&gt;</description>
    <pubDate>Thu, 29 Aug 2019 16:20:43 GMT</pubDate>
    <dc:creator>lavster</dc:creator>
    <dc:date>2019-08-29T16:20:43Z</dc:date>
    <item>
      <title>EVAL Total Duration in Minutes Across 2 Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465946#M191771</link>
      <description>&lt;P&gt;ive created a table with monitoring in for our daily checks&lt;/P&gt;

&lt;P&gt;However I still need to do an eval to get the Total Duration in Minutes for each service which is (“Test File End” – Test_Start)   &lt;/P&gt;

&lt;P&gt;In the example below I’ve shown in yellow my attempt to eval this field. It actually works when the fields I am using are not included in the join subsearch. However when I join on the subsearch field the field returns blank  &lt;/P&gt;

&lt;P&gt;It has been suggested to do this without a join but as its in a seperate index the data comes back blank for the file start and end fields. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test| bucket _time span=1d as Day | stats earliest(_time) as TEST_Start latest(_time) as TEST_End by Day
| eval TEST_Start=strftime(TEST_Start,"%H:%M:%S")
| eval TEST_End=strftime(TEST_End,"%H:%M:%S")
| eval Day=strftime(Day,"%d/%m/%Y")
| join Day [search index=test2 State=START Service="Testing" | bucket _time span=1d as Day | stats values(FileTime) as "TEST File Start" by Day | eval Day=strftime(Day,"%d/%m/%Y")]
| join Day [search index=test2 State=END Service="Testing" | bucket _time span=1d as Day | stats values(FileTime) as "Test File 
End" by Day | eval Day=strftime(Day,"%d/%m/%Y")]
| eval st = strptime(Test_Start,"%H:%M:%S") | eval et = strptime("Test File End","%H:%M:%S") | eval diff = et - st | eval "TEST_Total" = tostring(diff, "duration")
| fields Day Test_Start Test_End "Test File Start" "Test File End" "TEST_Total"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:15:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465946#M191771</guid>
      <dc:creator>lavster</dc:creator>
      <dc:date>2019-08-29T15:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: EVAL Total Duration in Minutes Across 2 Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465947#M191772</link>
      <description>&lt;P&gt;Do not use &lt;CODE&gt;join&lt;/CODE&gt;.  Show us a few sample events and a mockup of what the final output should be and then we can help.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:20:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465947#M191772</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-29T15:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: EVAL Total Duration in Minutes Across 2 Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465948#M191773</link>
      <description>&lt;P&gt;try this ?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test OR (index=test2 State=START Service="Testing") OR (index=test2 State=END Service="Testing") 
| bucket _time span=1d as Day 
| stats earliest(eval(case(index="test",_time))) as TEST_Start latest(eval(case(index="test",_time))) as TEST_End values(eval(case(index="test2" AND State="START",FileTime))) as "TEST File Start" values(eval(case(index="test2" AND State="END",FileTime))) as "TEST File End" by Day 
| eval TEST_Start=strftime(TEST_Start,"%H:%M:%S") 
| eval TEST_End=strftime(TEST_End,"%H:%M:%S") 
| eval Day=strftime(Day,"%d/%m/%Y") 
| eval st = strptime("TEST File Start","%H:%M:%S") 
| eval et = strptime("TEST File End","%H:%M:%S") 
| eval diff = et - st 
| eval "TEST_Total" = tostring(diff, "duration") 
| table Day Test_Start Test_End "Test File Start" "Test File End" "TEST_Total"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR you could change main search to &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=test OR (index=test2 (State=START OR State=END) Service="Testing") 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:32:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465948#M191773</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2019-08-29T15:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: EVAL Total Duration in Minutes Across 2 Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465949#M191774</link>
      <description>&lt;P&gt;Thanks i'll try this now.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:41:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465949#M191774</guid>
      <dc:creator>lavster</dc:creator>
      <dc:date>2019-08-29T15:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: EVAL Total Duration in Minutes Across 2 Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465950#M191775</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="index=test,Day=13/08/2019,Service=TEST,FileTime=08:24:48,State=START:::index=test,Day=13/08/2019,Service=TEST,FileTime=08:39:07,State=END:::index=test2,Day=13/08/2019,Service=TEST,FileTime=08:39:55,State=START:::index=test2,Day=13/08/2019,Service=TEST,FileTime=08:52:07,State=END" 
| makemv delim=":::" raw 
| mvexpand raw 
| rename raw AS _raw 
| kv 
| eval _time = strptime(Day . " " . FileTime, "%d/%m/%Y %H:%M:%S") 
| sort 0 - _time 

| rename COMMENT1of2 AS "Everything above generates smaple event data; evertying below is your solution"
| rename COMMENT2of2 AS "Replace everything above with a simple '(index=test OR index=test2) WITHOUT 'join'"

| eval Day=strptime(Day,"%d/%m/%Y") 
| fieldformat Day=strftime(Day,"%d/%m/%Y") 
| streamstats count(eval(State="END")) AS sessionID BY index Day Service
| stats range(_time) AS duration BY index Day Service sessionID
| eval {index} = duration
| fields - index duration
| stats values(*) AS * BY Day Service sessionID
| fieldformat test=tostring(test, "duration")
| fieldformat test2=tostring(test2, "duration")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Aug 2019 15:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465950#M191775</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-29T15:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: EVAL Total Duration in Minutes Across 2 Indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465951#M191776</link>
      <description>&lt;P&gt;Took a bit of fudging with but got the desired outcome. Thanks very much&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 16:20:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/EVAL-Total-Duration-in-Minutes-Across-2-Indexes/m-p/465951#M191776</guid>
      <dc:creator>lavster</dc:creator>
      <dc:date>2019-08-29T16:20:43Z</dc:date>
    </item>
  </channel>
</rss>

