<?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: Comparing different fields from different rows in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267307#M80417</link>
    <description>&lt;P&gt;Error in 'appendcols' command: You can only use appendcols after a reporting command (such as stats, chart, or timechart).&lt;/P&gt;</description>
    <pubDate>Wed, 07 Sep 2016 14:29:34 GMT</pubDate>
    <dc:creator>ozirus</dc:creator>
    <dc:date>2016-09-07T14:29:34Z</dc:date>
    <item>
      <title>Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267297#M80407</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I've a search query that returns 2 events with two different fields;&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/157226-ekran-al%C4%B1nt%C4%B1s%C4%B1.gif" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;EXTRA_FIELD_3 = XXXXXX&lt;BR /&gt;
GUNCELSAYI = YYYYYY&lt;/P&gt;

&lt;P&gt;I want to compare if EXTRA_FIELD_3 &amp;gt; GUNCELSAYI*2 and raise an alert.&lt;/P&gt;

&lt;P&gt;How can I do this?&lt;/P&gt;

&lt;P&gt;Regards,&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:53:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267297#M80407</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2020-09-29T10:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267298#M80408</link>
      <description>&lt;P&gt;please check if rex is extracting the fields properly.. then we can find the difference between two and create an alert - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your search | rex field=_raw "EXTRA_FIELD_3\s\=\s(?&amp;lt;EXTRA_FIELD_VALUE&amp;gt;\d+[^\n]) | rex field=_raw "GUNCELSAYI\s\=\s (?&amp;lt;GUNCELSAYI_VALUE&amp;gt;\d+[^\n]) | table EXTRA_FIELD_VALUE, GUNCELSAYI_VALUE
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 13:34:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267298#M80408</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2016-09-07T13:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267299#M80409</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | streamstats window=1 current=f values(GUNCELSAYI)  as GUNCELSAYI | where isnotnull(EXTRA_FIELD_3)  AND EXTRA_FIELD_3 &amp;gt; GUNCELSAYI*2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Sep 2016 13:39:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267299#M80409</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-09-07T13:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267300#M80410</link>
      <description>&lt;P&gt;My query is;&lt;/P&gt;

&lt;P&gt;host="AVGMAILCOUNT" date_wday = [|stats count | eval A=strftime(now(),"%A") | return $A] | addinfo | eval saat=strftime(info_search_time,"%H") | eval dakka=strftime(info_search_time,"%M") | eval sonuc=if( date_hour == saat AND date_minute == dakka, "Evet","Hayır") | search sonuc=Evet | append [search index=websense earliest=-10m | stats count as GUNCELSAYI]&lt;/P&gt;

&lt;P&gt;When I add  "| rex field=_raw "EXTRA_FIELD_3\s=\s(?\d+[^\n]) | rex field=_raw "GUNCELSAYI\s=\s (?\d+[^\n]) | table EXTRA_FIELD_VALUE, GUNCELSAYI_VALUE" to this; &lt;/P&gt;

&lt;P&gt;this gives  &lt;/P&gt;

&lt;P&gt;Error in 'SearchParser': Missing a search command before '^'. &lt;/P&gt;

&lt;P&gt;Any idea?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:53:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267300#M80410</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2020-09-29T10:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267301#M80411</link>
      <description>&lt;P&gt;sorry, updated the missing double quotes - &lt;/P&gt;

&lt;P&gt;rex field=_raw "EXTRA_FIELD_3\s=\s(?\d+[^\n])" | rex field=_raw "GUNCELSAYI\s=\s (?\d+[^\n])" | table EXTRA_FIELD_VALUE, GUNCELSAYI_VALUE&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:50:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267301#M80411</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-09-29T10:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267302#M80412</link>
      <description>&lt;P&gt;It didn't return any result while I try both &amp;gt; and &amp;lt; in last compare statement Empty.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 13:56:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267302#M80412</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2016-09-07T13:56:22Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267303#M80413</link>
      <description>&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'EXTRA_FIELD_3\s=\s(?\d+[^\n])': Regex: unrecognized character after (? or (?-&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:53:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267303#M80413</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2020-09-29T10:53:35Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267304#M80414</link>
      <description>&lt;P&gt;BTW, EXTRA_FIELD_3 and GUNCELSAYI are both fields and values after = is field values. They're not single string like "GUNCELSAYI=2" &lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:53:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267304#M80414</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2020-09-29T10:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267305#M80415</link>
      <description>&lt;P&gt;They are not string. They are fields with values&lt;/P&gt;

&lt;P&gt;FieldName = Value&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 14:17:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267305#M80415</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2016-09-07T14:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267306#M80416</link>
      <description>&lt;P&gt;Try like this (using appendcols function will add the search result of 2nd query as column available in same events and it would be easy to compare)&lt;BR /&gt;
&lt;STRONG&gt;Updated&lt;/STRONG&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="AVGMAILCOUNT" date_wday = [|stats count | eval A=strftime(now(),"%A") | return $A] | addinfo | eval saat=strftime(info_search_time,"%H") | eval dakka=strftime(info_search_time,"%M") | eval sonuc=if( date_hour == saat AND date_minute == dakka, "Evet","Hayır") | search sonuc=Evet | stats values(*) as * | appendcols [search index=websense earliest=-10m | stats count as GUNCELSAY ] | where EXTRA_FIELD_3 &amp;gt; GUNCELSAYI*2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you results when your condition is fulfilled. You can save this as &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.4.3/Alert/Emailnotification#Configure_email_notification_from_the_Search_or_Alerts_page"&gt;alert&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 14:18:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267306#M80416</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-07T14:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267307#M80417</link>
      <description>&lt;P&gt;Error in 'appendcols' command: You can only use appendcols after a reporting command (such as stats, chart, or timechart).&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 14:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267307#M80417</guid>
      <dc:creator>ozirus</dc:creator>
      <dc:date>2016-09-07T14:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing different fields from different rows</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267308#M80418</link>
      <description>&lt;P&gt;Oops.. try the updated answer.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2016 14:31:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Comparing-different-fields-from-different-rows/m-p/267308#M80418</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-07T14:31:29Z</dc:date>
    </item>
  </channel>
</rss>

