<?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 Using comparison function within mstats in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Using-comparison-function-within-mstats/m-p/658862#M227549</link>
    <description>&lt;P&gt;Hello fellow Splunkthiasts!&lt;/P&gt;&lt;P&gt;I need some insights to understand how comparison functions in mstats could be used. Consider the following query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats latest(cpu_metric.*) as * WHERE index="osnix_metrics" sourcetype=cpu_metric CPU=all BY host
| where pctUser &amp;gt; 50&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As expected, it returns a list of hosts having latest CPU usage value higher than 50%.&lt;/P&gt;&lt;P&gt;However, according to mstats command reference, I can have comparison expression within WHERE clause and I'd expect it would be more efficient to rewrite the above query like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats latest(cpu_metric.*) as * WHERE index="osnix_metrics" sourcetype=cpu_metric CPU=all pctUser &amp;gt; 50 BY host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, this doesn't return any results. I tried to refer to metric before aggregation with no luck:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats latest(cpu_metric.*) as * WHERE index="osnix_metrics" sourcetype=cpu_metric CPU=all cpu_metric.pctUser &amp;gt; 50 BY host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2023 11:26:22 GMT</pubDate>
    <dc:creator>eregon</dc:creator>
    <dc:date>2023-09-27T11:26:22Z</dc:date>
    <item>
      <title>Using comparison function within mstats</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Using-comparison-function-within-mstats/m-p/658862#M227549</link>
      <description>&lt;P&gt;Hello fellow Splunkthiasts!&lt;/P&gt;&lt;P&gt;I need some insights to understand how comparison functions in mstats could be used. Consider the following query:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats latest(cpu_metric.*) as * WHERE index="osnix_metrics" sourcetype=cpu_metric CPU=all BY host
| where pctUser &amp;gt; 50&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As expected, it returns a list of hosts having latest CPU usage value higher than 50%.&lt;/P&gt;&lt;P&gt;However, according to mstats command reference, I can have comparison expression within WHERE clause and I'd expect it would be more efficient to rewrite the above query like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats latest(cpu_metric.*) as * WHERE index="osnix_metrics" sourcetype=cpu_metric CPU=all pctUser &amp;gt; 50 BY host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, this doesn't return any results. I tried to refer to metric before aggregation with no luck:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats latest(cpu_metric.*) as * WHERE index="osnix_metrics" sourcetype=cpu_metric CPU=all cpu_metric.pctUser &amp;gt; 50 BY host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 11:26:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Using-comparison-function-within-mstats/m-p/658862#M227549</guid>
      <dc:creator>eregon</dc:creator>
      <dc:date>2023-09-27T11:26:22Z</dc:date>
    </item>
  </channel>
</rss>

