<?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: mstats with host subquery in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527743#M148989</link>
    <description>&lt;P&gt;Run the subsearch by itself with "| format" appended to it.&amp;nbsp; You should get something that looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(host="foo" OR host="bar" OR host="baz")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add that to the main search to get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND host in (host="foo" OR host="bar" OR host="baz")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and you should see the problem.&amp;nbsp; The string returned by the subsearch makes no sense in the context of the main search.&amp;nbsp; The solution is to modify one or both searches so the result is good SPL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND 
  [search stuff stuff stuff 
  | rename host as host_changed 
  | return host_changed] by host span=1m 
| timechart span=1m avg(load.longterm) AS Longterm by host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Nov 2020 14:46:43 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2020-11-03T14:46:43Z</dc:date>
    <item>
      <title>mstats with host subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527622#M148952</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I have this query which gets me the list of hosts&lt;/P&gt;&lt;P&gt;stuff stuff stuff | rename host as host_changed | dedup host_changed | table host_changed&lt;/P&gt;&lt;P&gt;it works beautifully. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I have this other query&lt;/P&gt;&lt;P&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND host=lalalala by host span=1m | timechart span=1m avg(load.longterm) AS Longterm by host&lt;/P&gt;&lt;P&gt;which also works perfectly&lt;/P&gt;&lt;P&gt;Now, what I want to do, it effectively combine the two, but I cannot seem to get the syntax right&lt;/P&gt;&lt;P&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND host in [search&amp;nbsp;stuff stuff stuff | rename host as host_changed | dedup host_changed | table host_changed] by host span=1m | timechart span=1m avg(load.longterm) AS Longterm by host&lt;/P&gt;&lt;P&gt;Thoughts? &amp;nbsp;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 01:47:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527622#M148952</guid>
      <dc:creator>matthewwhittle</dc:creator>
      <dc:date>2020-11-03T01:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: mstats with host subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527743#M148989</link>
      <description>&lt;P&gt;Run the subsearch by itself with "| format" appended to it.&amp;nbsp; You should get something that looks like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(host="foo" OR host="bar" OR host="baz")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add that to the main search to get&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND host in (host="foo" OR host="bar" OR host="baz")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and you should see the problem.&amp;nbsp; The string returned by the subsearch makes no sense in the context of the main search.&amp;nbsp; The solution is to modify one or both searches so the result is good SPL.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND 
  [search stuff stuff stuff 
  | rename host as host_changed 
  | return host_changed] by host span=1m 
| timechart span=1m avg(load.longterm) AS Longterm by host&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2020 14:46:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527743#M148989</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-11-03T14:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: mstats with host subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527976#M149045</link>
      <description>&lt;P&gt;Hi richgalloway,&lt;/P&gt;&lt;P&gt;Your response is very appreciated. &amp;nbsp;When I tried your suggestion below, I got the error&lt;/P&gt;&lt;P&gt;"&lt;SPAN&gt;Term based search is not supported"&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527976#M149045</guid>
      <dc:creator>matthewwhittle</dc:creator>
      <dc:date>2020-11-04T17:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: mstats with host subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527978#M149047</link>
      <description>&lt;P&gt;Ah, but a theme off that variation works, taking the approach of modifying the mstats query&lt;/P&gt;&lt;P&gt;| mstats prestats=true avg(load.*) WHERE (`sai_metrics_indexes`) AND&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;[search stuff stuff stuff&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;| format] by host span=1m&lt;/P&gt;&lt;P&gt;| timechart span=1m avg(load.longterm) AS Longterm by host&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 17:48:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/mstats-with-host-subquery/m-p/527978#M149047</guid>
      <dc:creator>matthewwhittle</dc:creator>
      <dc:date>2020-11-04T17:48:06Z</dc:date>
    </item>
  </channel>
</rss>

