<?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 use Eval greater than, less than  for a duration and Count the values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458355#M129433</link>
    <description>&lt;P&gt;@tiagofbmm This is exactly what I was looking for. Thank you&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jul 2019 19:17:14 GMT</pubDate>
    <dc:creator>amunag439</dc:creator>
    <dc:date>2019-07-09T19:17:14Z</dc:date>
    <item>
      <title>How to use Eval greater than, less than  for a duration and Count the values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458350#M129428</link>
      <description>&lt;P&gt;I'm calculating the time difference between two events by using Transaction and Duration. Below is the query that I used to get the duration between two events Model and Response&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=* sourcetype=** source="*/example.log" "Model*" OR "Response*"
 | transaction traceId startswith="Model" endswith="Response" 
 | table traceId duration _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to get counts of transactions where duration&amp;gt;1, duration&amp;lt;1 and the total count in the same table. I was able to do it individually in separate queries using where clause and eval. But was not successful when I combined them. The individual query that works for me is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Model List*" OR "Response Code*"
| transaction traceId startswith="Model List" endswith="Response Code" | eval less_dur=duration | where less_dur &amp;gt; 1
| stats count(less_dur)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Query that &lt;STRONG&gt;doesnt&lt;/STRONG&gt; work me is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"Model List*" OR "Response Code*"
| transaction traceId startswith="Model List" endswith="Response Code" | eval less_dur=duration | where less_dur &amp;gt; 1 | eval more_dur=duration | where more_dur &amp;lt; 1
| stats count(less_dur), count(more_dur), count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 17:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458350#M129428</guid>
      <dc:creator>amunag439</dc:creator>
      <dc:date>2019-07-09T17:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval greater than, less than  for a duration and Count the values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458351#M129429</link>
      <description>&lt;P&gt;So the reason that wouldn't work is because you're calculating less_dur and then filtering when it's less than 1. THEN you create more_dur, but the duration is already always less than 1. you would need to do both evals before the where statements.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:16:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458351#M129429</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2020-09-30T01:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval greater than, less than  for a duration and Count the values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458352#M129430</link>
      <description>&lt;P&gt;@cmerriman My eval is based on the duration values here. So how do I achieve it?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 18:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458352#M129430</guid>
      <dc:creator>amunag439</dc:creator>
      <dc:date>2019-07-09T18:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval greater than, less than  for a duration and Count the values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458353#M129431</link>
      <description>&lt;P&gt;I think there is a logical loop here. You're looking for duration&amp;gt;1 and then duration &amp;lt;1 and want to have the number of each of those.&lt;/P&gt;

&lt;P&gt;How about&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; "Model List*" OR "Response Code*"
 | transaction traceId startswith="Model List" endswith="Response Code" | eval less_dur=if(duration&amp;gt;1,1,0), moe_dur=if(duration&amp;lt;1,1,0)  | stats sum(less_dur), sum(more_dur), count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 18:55:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458353#M129431</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2019-07-09T18:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval greater than, less than  for a duration and Count the values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458354#M129432</link>
      <description>&lt;P&gt;Thanks for the reply @cmerriman &lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 19:16:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458354#M129432</guid>
      <dc:creator>amunag439</dc:creator>
      <dc:date>2019-07-09T19:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Eval greater than, less than  for a duration and Count the values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458355#M129433</link>
      <description>&lt;P&gt;@tiagofbmm This is exactly what I was looking for. Thank you&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 19:17:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-Eval-greater-than-less-than-for-a-duration-and-Count/m-p/458355#M129433</guid>
      <dc:creator>amunag439</dc:creator>
      <dc:date>2019-07-09T19:17:14Z</dc:date>
    </item>
  </channel>
</rss>

