<?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 a conditional variable in a stats count command? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261864#M78620</link>
    <description>&lt;P&gt;Considering there are only 5 Actions, you can use eval case command to specify/use the SLA for each action. Try this. Replace SLAfor* with appropriate values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* (Action=Search OR Action=CreateOrder OR Action=FindItinerary OR Action=Confirm OR Action=CreditRefund_Confirm) 
 | bin _time span=1d 
| eval Latent=case(Action="Search" AND DurationTotal&amp;gt;SLAforSearch,1,Action="CreateOrder" AND DurationTotal&amp;gt;SLAforCreateOrder,1, Action="FindItinerary" AND DurationTotal&amp;gt;SLAforFindItinerary,1,Action="Confirm" AND DurationTotal&amp;gt;SLAforConfirm,1, Action="CreditRefund_Confirm" AND DurationTotal&amp;gt;SLAforCreditRefund_Confirm,1, true(),0)
 | stats count as Total, sum(Latest) as Latent by _time Action
 | eval Percent=round(100-((Latent*100)/Total),2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Jan 2017 22:07:25 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-01-26T22:07:25Z</dc:date>
    <item>
      <title>How to use a conditional variable in a stats count command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261863#M78619</link>
      <description>&lt;P&gt;Given the following search logic&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* (Action=Search OR Action=CreateOrder OR Action=FindItinerary OR Action=Confirm OR Action=CreditRefund_Confirm) 
| bin _time span=1d
| stats count as Total, count(eval(DurationTotal&amp;gt;$ActionSLA$) AS Latent by _time Action
| eval Percent=round(100-((Latent*100)/Total),2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to have the $ActionSLA$ variable in the above pseudocode be different for each action so that I end up with results that look like the following where the Latent field is driven by the ActionSLA per Action.  For instance Search ActionSLA=2000 when Action=Search, ActionSLA=4000 when Action=CreateOrder, etc.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time              Action              Total    Latent  Percent
2017-01-26 09:00    Confirm           1259   864       31.37
2017-01-26 09:00    CreateOrder       611     147      75.94
2017-01-26 09:00    CreditRefund_Confirm 333      237      28.83
2017-01-26 09:00    FindItinerary       12461   2155      82.71
2017-01-26 09:00    Search             8349  3481     58.31
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 21:39:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261863#M78619</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2017-01-26T21:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a conditional variable in a stats count command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261864#M78620</link>
      <description>&lt;P&gt;Considering there are only 5 Actions, you can use eval case command to specify/use the SLA for each action. Try this. Replace SLAfor* with appropriate values.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* (Action=Search OR Action=CreateOrder OR Action=FindItinerary OR Action=Confirm OR Action=CreditRefund_Confirm) 
 | bin _time span=1d 
| eval Latent=case(Action="Search" AND DurationTotal&amp;gt;SLAforSearch,1,Action="CreateOrder" AND DurationTotal&amp;gt;SLAforCreateOrder,1, Action="FindItinerary" AND DurationTotal&amp;gt;SLAforFindItinerary,1,Action="Confirm" AND DurationTotal&amp;gt;SLAforConfirm,1, Action="CreditRefund_Confirm" AND DurationTotal&amp;gt;SLAforCreditRefund_Confirm,1, true(),0)
 | stats count as Total, sum(Latest) as Latent by _time Action
 | eval Percent=round(100-((Latent*100)/Total),2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Jan 2017 22:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261864#M78620</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-01-26T22:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a conditional variable in a stats count command?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261865#M78621</link>
      <description>&lt;P&gt;Ha, this is exactly what I was thinking of doing as well, but the syntax was throwing me.  This did in fact work, thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 22:43:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-a-conditional-variable-in-a-stats-count-command/m-p/261865#M78621</guid>
      <dc:creator>Cuyose</dc:creator>
      <dc:date>2017-01-26T22:43:08Z</dc:date>
    </item>
  </channel>
</rss>

