<?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 run two searches and table the results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333791#M99256</link>
    <description>&lt;P&gt;|search1 | append [|search2] |  timechart count span=1d | timewrap 1week&lt;/P&gt;</description>
    <pubDate>Fri, 09 Mar 2018 08:58:09 GMT</pubDate>
    <dc:creator>valiquet</dc:creator>
    <dc:date>2018-03-09T08:58:09Z</dc:date>
    <item>
      <title>How to run two searches and table the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333790#M99255</link>
      <description>&lt;P&gt;Good afternoon Guys, &lt;/P&gt;

&lt;P&gt;Second question in as many days, but this one is puzzling me and my tiny useless uneducated brain simply cannot work it out. &lt;/P&gt;

&lt;P&gt;So, the concept is thus - We ingest an email into our &lt;STRONG&gt;mail&lt;/STRONG&gt; index, we then will extract the &lt;STRONG&gt;jobname, start date,start time, end date, end time&lt;/STRONG&gt; and then produce a &lt;STRONG&gt;run time&lt;/STRONG&gt;. From this, we can then compare the same job run time from the week previous and produce an alert when say the run time has increased by 10%. With me or have I made a right mess of that?!&lt;/P&gt;

&lt;P&gt;I have created a &lt;EM&gt;HORRIBLE&lt;/EM&gt; search so far that looks like this:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mail sourcetype=imap cprd 
| rex field=_raw "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+)\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})..([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})\s*([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" max_match=0 
| mvexpand Jobname
| rex field=Jobname "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+))\s*(?&amp;lt;LastRunStartDate&amp;gt;([0-9]{2}\/[0-9]{2}\/[0-9]{4})).(?&amp;lt;LastRunStartTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastRunEndDate&amp;gt;(..([0-9]{2}\/[0-9]{2}\/[0-9]{4}))).(?&amp;lt;LastRunEndTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastStatus&amp;gt;([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))"
| convert timeformat="%T" mktime(LastRunStartTime)  
| fieldformat LastRunStartTime=strftime(LastRunStartTime,"%H:%M:%S")
| convert timeformat="%T" mktime(LastRunEndTime)
| fieldformat LastRunEndTime=strftime(LastRunEndTime,"%T")
| eval RunTime=LastRunEndTime-LastRunStartTime
| rename RunTime as "Run Time (Mins &amp;amp; Secs)"
| table Jobname LastRunStartTime LastRunEndTime "Run Time (Mins &amp;amp; Secs)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know, I know, you've probably looked at that and thought - &lt;EM&gt;"Oh my, silly boy, could be done so much simpler"&lt;/EM&gt; and you're right, it can, but I am still very much a junior with regards to splunk searching and methodology. SO, brace yourselves for the next part. What i then want to do is run the same search but for a previous date and compare the run time to list the resulting difference. I have attempted it, and it's horrible:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mail sourcetype=imap cprd latest="03/03/2018:15:00:00"
| rex field=_raw "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+)\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})..([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})\s*([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" max_match=0 
| mvexpand Jobname
| rex field=Jobname "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+))\s*(?&amp;lt;LastRunStartDate&amp;gt;([0-9]{2}\/[0-9]{2}\/[0-9]{4})).(?&amp;lt;LastRunStartTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastRunEndDate&amp;gt;(..([0-9]{2}\/[0-9]{2}\/[0-9]{4}))).(?&amp;lt;LastRunEndTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastStatus&amp;gt;([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))"
| convert timeformat="%T" mktime(LastRunStartTime)  
| fieldformat LastRunStartTime=strftime(LastRunStartTime,"%H:%M:%S")
| convert timeformat="%T" mktime(LastRunEndTime)
| fieldformat LastRunEndTime=strftime(LastRunEndTime,"%T")
| eval RunTime = LastRunEndTime - LastRunStartTime 
| stats list(Jobname) as Job list(RunTime) as Todays_Run
| appendcols
    [search index=mail sourcetype=imap cprd latest="07/03/2018:10:00:00"
| rex field=_raw "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+)\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})..([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})\s*([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" max_match=0 
| mvexpand Jobname
| rex field=Jobname "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+))\s*(?&amp;lt;LastRunStartDate&amp;gt;([0-9]{2}\/[0-9]{2}\/[0-9]{4})).(?&amp;lt;LastRunStartTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastRunEndDate&amp;gt;(..([0-9]{2}\/[0-9]{2}\/[0-9]{4}))).(?&amp;lt;LastRunEndTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastStatus&amp;gt;([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))"
| convert timeformat="%T" mktime(LastRunStartTime)  
| fieldformat LastRunStartTime=strftime(LastRunStartTime,"%H:%M:%S")
| convert timeformat="%T" mktime(LastRunEndTime)
| fieldformat LastRunEndTime=strftime(LastRunEndTime,"%T")
| eval RunTime2 = LastRunEndTime - LastRunStartTime
| stats list(Jobname) as Job list(RunTime2) as Previous_Run]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's not very happy with this and throwing, understandably, some truncation warnings. Thing is, it kind of works, but now it is listing everything as one statistic again so I cannot run an eval on &lt;STRONG&gt;Todays_run&lt;/STRONG&gt; and &lt;STRONG&gt;previous_run&lt;/STRONG&gt;. I would reeeeaaallllyy value someone taking a look at this mess and suggesting a much cleaner way to achieve this that my simple mind could comprehend. Thanks guys &amp;amp; gals!&lt;/P&gt;</description>
      <pubDate>Wed, 07 Mar 2018 15:11:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333790#M99255</guid>
      <dc:creator>Barty</dc:creator>
      <dc:date>2018-03-07T15:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to run two searches and table the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333791#M99256</link>
      <description>&lt;P&gt;|search1 | append [|search2] |  timechart count span=1d | timewrap 1week&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 08:58:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333791#M99256</guid>
      <dc:creator>valiquet</dc:creator>
      <dc:date>2018-03-09T08:58:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to run two searches and table the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333792#M99257</link>
      <description>&lt;P&gt;Thank you for the response, I'm a little confused as to what exactly I am asking the timechart to count on though?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 09:29:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333792#M99257</guid>
      <dc:creator>Barty</dc:creator>
      <dc:date>2018-03-09T09:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to run two searches and table the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333793#M99258</link>
      <description>&lt;P&gt;Hey Barty ,&lt;BR /&gt;
 Can you try something like dis:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=mail sourcetype=imap cprd latest="03/03/2018:15:00:00" 
| rex field=_raw max_match=0 "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+)\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})..([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})\s*([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" 
| mvexpand Jobname 
| rex field=Jobname "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+))\s*(?&amp;lt;LastRunStartDate&amp;gt;([0-9]{2}\/[0-9]{2}\/[0-9]{4})).(?&amp;lt;LastRunStartTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastRunEndDate&amp;gt;(..([0-9]{2}\/[0-9]{2}\/[0-9]{4}))).(?&amp;lt;LastRunEndTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastStatus&amp;gt;([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" 
| eval LastRunStartTime=strptime(LastRunStartTime,"%H:%M:%S"),LastRunEndTime=strptime(LastRunEndTime,"%H:%M:%S") 
| eval RunTime=LastRunEndTime-LastRunStartTime 
| eval RunTime=strftime(RunTime,"%H:%M:%S") 
| stats values(RunTime) as Previous_Run by jobname 
| join Jobname 
    [ index=mail sourcetype=imap cprd latest="07/03/2018:10:00:00"
    | rex field=_raw max_match=0 "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+)\s*([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})..([0-9]{2}\/[0-9]{2}\/[0-9]{4}).([0-9]{2}:[0-9]{2}:[0-9]{2})\s*([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" 
    | mvexpand Jobname 
    | rex field=Jobname "(?&amp;lt;Jobname&amp;gt;(p-c[a-z\-]+))\s*(?&amp;lt;LastRunStartDate&amp;gt;([0-9]{2}\/[0-9]{2}\/[0-9]{4})).(?&amp;lt;LastRunStartTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastRunEndDate&amp;gt;(..([0-9]{2}\/[0-9]{2}\/[0-9]{4}))).(?&amp;lt;LastRunEndTime&amp;gt;([0-9]{2}:[0-9]{2}:[0-9]{2})|-{5})\s*(?&amp;lt;LastStatus&amp;gt;([SU]{2}|[RU]{2}|[FA]{2}|[IN]{2}))" 
    | eval LastRunStartTime=strptime(LastRunStartTime,"%H:%M:%S"),LastRunEndTime=strptime(LastRunEndTime,"%H:%M:%S") 
    | eval RunTime=LastRunEndTime-LastRunStartTime 
    | eval RunTime=strftime(RunTime,"%H:%M:%S") 
    | stats values(RunTime) as Todays_Run by jobname] 
| table Jobname Previous_Run Todays_Run 
| eval Percentage=round((Todays_Run-Previous_Run/Todays_Run)*100) 
| search Percentage&amp;gt;10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!!!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 10:55:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333793#M99258</guid>
      <dc:creator>deepashri_123</dc:creator>
      <dc:date>2018-03-09T10:55:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to run two searches and table the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333794#M99259</link>
      <description>&lt;P&gt;Good afternoon! I've tried this, and sadly no luck! I remediated the slight issue in as much as there was a missing 'search' after the join, but still no luck in any results.. so close!&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:02:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333794#M99259</guid>
      <dc:creator>Barty</dc:creator>
      <dc:date>2018-03-09T14:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to run two searches and table the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333795#M99260</link>
      <description>&lt;P&gt;timewrap will superpose your 2 timecharts representing 2 different time period&lt;/P&gt;</description>
      <pubDate>Fri, 09 Mar 2018 14:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-run-two-searches-and-table-the-results/m-p/333795#M99260</guid>
      <dc:creator>valiquet</dc:creator>
      <dc:date>2018-03-09T14:16:51Z</dc:date>
    </item>
  </channel>
</rss>

