<?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 fetch and compare the top/first row from two source types? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253891#M76021</link>
    <description>&lt;P&gt;Yes. Its giving the expected results. &lt;BR /&gt;
I have additionally added &lt;CODE&gt;| fillnull value="Not running"&lt;/CODE&gt; to the below query as &lt;CODE&gt;Status&lt;/CODE&gt; and &lt;CODE&gt;Status_r&lt;/CODE&gt; fields have blanks values when &lt;CODE&gt;Running&lt;/CODE&gt; is not found in FX.&lt;BR /&gt;
But this made the query slow. Is there any way to do fillnull during FX or during indexing?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="join_test1" (sourcetype="Monitor_join_test" OR sourcetype="Response_join_test") 
    | fillnull value="Not running"
    | stats latest(Status*) as Status* by sourcetype
    | stats values(Status*) as Status*
    | eval running_ok = if(Status="Running" AND Status_r="Running", 0, 1) 
    | eval final = if(running_ok=0, 0, 1) 
    | table final|outputlookup output.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 06 Dec 2016 12:48:46 GMT</pubDate>
    <dc:creator>email2vamsi</dc:creator>
    <dc:date>2016-12-06T12:48:46Z</dc:date>
    <item>
      <title>How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253884#M76014</link>
      <description>&lt;P&gt;I would like to fetch the latest record (only the first row) from two source types and check if both the fields are zeros or not.&lt;BR /&gt;
It's a success if both have zeros, else it's a failure if either of them is 1.&lt;/P&gt;

&lt;P&gt;The following query is near to the requirement, but the &lt;STRONG&gt;Status_r&lt;/STRONG&gt; field never shows up to compare as it has the older time stamp.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="join_test1" sourcetype="Monitor_join_test" OR sourcetype="Response_join_test"  | eval running_ok = if(Status="0" AND Status_r="0","0","1") |head 1
|eval final = if(running_ok==0,0,1) |table running_ok Status Status_r final
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Dec 2016 11:57:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253884#M76014</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2016-12-02T11:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253885#M76015</link>
      <description>&lt;P&gt;How about this query?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="join_test1" (sourcetype="Monitor_join_test" OR sourcetype="Response_join_test") 
 | stats latest(Status*) as Status* by sourcetype
 | fillnull value=0
 | stats max(Status*) as Status*
 | eval running_ok = if(tonumber(Status)=0 AND tonumber(Status_r)=0, 0, 1) 
 | eval final = if(running_ok=0, 0, 1) 
 | table running_ok Status Status_r final
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Dec 2016 12:26:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253885#M76015</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-02T12:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253886#M76016</link>
      <description>&lt;P&gt;Thank you. It works for numbers.&lt;BR /&gt;
I have changed &lt;CODE&gt;if(tonumber(Status)=0 AND tonumber(Status_r)=0, 0, 1)&lt;/CODE&gt; to the following&lt;BR /&gt;
 &lt;CODE&gt;| eval running_ok = if(Status="Running" AND Status_r="Running", 0, 1)&lt;/CODE&gt;. Here i am check for String,&lt;BR /&gt;
Then its not giving the expected results. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index="join_test1" (sourcetype="Monitor_join_test" OR sourcetype="Response_join_test") 
  | stats latest(Status*) as Status* by sourcetype
  | fillnull value=0
  | stats max(Status*) as Status*
  | eval running_ok = if(Status="Running" AND Status_r="Running", 0, 1) 
  | eval final = if(running_ok=0, 0, 1) 
  | table running_ok Status Status_r final
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2016 10:12:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253886#M76016</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2016-12-05T10:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253887#M76017</link>
      <description>&lt;P&gt;You would to change the first few parts as well where you are combining the fields into a single table result.&lt;/P&gt;

&lt;P&gt;To be clear, are you expecting strings in the real data or is there a mixture of strings and numbers?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 10:42:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253887#M76017</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-05T10:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253888#M76018</link>
      <description>&lt;P&gt;I am doing field extraction and assigning the Running  to &lt;CODE&gt;Status="Running"&lt;/CODE&gt;.&lt;BR /&gt;
So  the the real events contain "Running".  I am not extracting any numbers from events.&lt;/P&gt;

&lt;P&gt;I want to compare this Status and Status_r fields from two source types and assign 0 or 1 to the "Final" variable.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;...| table final | outputlookup ouput.csv&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 10:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253888#M76018</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2016-12-05T10:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253889#M76019</link>
      <description>&lt;P&gt;Then try this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="join_test1" (sourcetype="Monitor_join_test" OR sourcetype="Response_join_test") 
   | stats latest(Status*) as Status* by sourcetype
   | stats values(Status*) as Status*
   | eval running_ok = if(Status="Running" AND Status_r="Running", 0, 1) 
   | eval final = if(running_ok=0, 0, 1) 
   | table running_ok Status Status_r final
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Dec 2016 11:00:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253889#M76019</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-05T11:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253890#M76020</link>
      <description>&lt;P&gt;Did this recommendation work?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2016 12:30:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253890#M76020</guid>
      <dc:creator>rjthibod</dc:creator>
      <dc:date>2016-12-06T12:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to fetch and compare the top/first row from two source types?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253891#M76021</link>
      <description>&lt;P&gt;Yes. Its giving the expected results. &lt;BR /&gt;
I have additionally added &lt;CODE&gt;| fillnull value="Not running"&lt;/CODE&gt; to the below query as &lt;CODE&gt;Status&lt;/CODE&gt; and &lt;CODE&gt;Status_r&lt;/CODE&gt; fields have blanks values when &lt;CODE&gt;Running&lt;/CODE&gt; is not found in FX.&lt;BR /&gt;
But this made the query slow. Is there any way to do fillnull during FX or during indexing?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="join_test1" (sourcetype="Monitor_join_test" OR sourcetype="Response_join_test") 
    | fillnull value="Not running"
    | stats latest(Status*) as Status* by sourcetype
    | stats values(Status*) as Status*
    | eval running_ok = if(Status="Running" AND Status_r="Running", 0, 1) 
    | eval final = if(running_ok=0, 0, 1) 
    | table final|outputlookup output.csv
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Dec 2016 12:48:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-fetch-and-compare-the-top-first-row/m-p/253891#M76021</guid>
      <dc:creator>email2vamsi</dc:creator>
      <dc:date>2016-12-06T12:48:46Z</dc:date>
    </item>
  </channel>
</rss>

