<?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: subsearch -  Busy Hour CPU usage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96319#M24883</link>
    <description>&lt;P&gt;The thing is that when you've run the &lt;CODE&gt;chart&lt;/CODE&gt; command, the fields you're trying to filter on do not exist anymore. The only fields you have available after the last &lt;CODE&gt;chart&lt;/CODE&gt; command are the ones it produces - AvgUsedPct and day.&lt;/P&gt;</description>
    <pubDate>Fri, 25 Jan 2013 12:20:50 GMT</pubDate>
    <dc:creator>Ayn</dc:creator>
    <dc:date>2013-01-25T12:20:50Z</dc:date>
    <item>
      <title>subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96312#M24876</link>
      <description>&lt;P&gt;I am running into some difficulties graphing some servers Used CPU % in the &lt;A href="http://en.wikipedia.org/wiki/Busy_hour" target="_blank"&gt;Busy Hour&lt;/A&gt;,&lt;BR /&gt;&lt;BR /&gt;
(spanning at least 2 months) for that I am trying to join a subsearch to a main search,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=resources_reporting source=*/output/ora_queries/client07/OS_metrics.csv HOST_NAME=*sdp* | eval CpuUsedPct=USED_CPU
| convert timeformat="%y-%m-%d" ctime(_time) as day
| append
[search index=resources_reporting source="*output/ora_queries/client07/SdpTermCauses.csv" PLATFORM=P1 
| convert timeformat="%y-%m-%d" ctime(_time) as day
| stats sum(SERVICE_EVOCATIONS) as ServiceEvocationsSum by date_hour day
| eventstats max(ServiceEvocationsSum) as MaxServiceEvocationsSum by day
| where ServiceEvocationsSum=MaxServiceEvocationsSum
| rename day AS BusyHourDay, date_hour AS BusyHour
| fields BusyHourDay BusyHour
] 
| convert timeformat="%y-%m-%d" ctime(_time) as day
| chart avg(CpuUsedPct) as AvgUsedCpuPct over day
| where date_hour=BusyHour day=BusyHourDay
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I get the AvgUsedCpuPct for each day Busy Hour ?&lt;BR /&gt;&lt;BR /&gt;
I've tried Ayn incremental functions suggestion but I'm really having trouble getting the where clause right.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;EDIT&lt;/STRONG&gt;&lt;BR /&gt;
Ended up using&lt;/P&gt;

&lt;P&gt;MAIN_SEARCH [search SUB_SEARCH&lt;BR /&gt;
| fields date_month, date_mday, date_hour&lt;BR /&gt;
]&lt;BR /&gt;
| eval CpuUsedPct=USED_CPU&lt;BR /&gt;
| timechart avg(CpuUsedPct) as AvgUsedCpuPct&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 13:10:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96312#M24876</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2020-09-28T13:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96313#M24877</link>
      <description>&lt;P&gt;You're tacking the subsearch directly onto the &lt;CODE&gt;eval&lt;/CODE&gt; command. A subsearch works very much like backticks in &lt;CODE&gt;*NIX&lt;/CODE&gt; systems, in that it runs first of all and returns its values to the outer search. In your case, you have&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval CpuUsedPct=USED_CPU [search ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which after the subsearch returns its results will expand to something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval CpuUsedPct=USED_CPU ((BusyHourDay= ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will of course make &lt;CODE&gt;eval&lt;/CODE&gt; think you want to call USED_CPU as some kind of function, which won't work since there's no such function to &lt;CODE&gt;eval&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Perhaps you meant to append the second search to the first?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | eval CpuUsedPct=USED_CPU | append [search ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2013 10:03:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96313#M24877</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-01-23T10:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96314#M24878</link>
      <description>&lt;P&gt;Thanks for the explanation Ayn !&lt;BR /&gt;
Makes more sense now,&lt;BR /&gt;
I've slightly changed the search but I am still getting the error,&lt;/P&gt;

&lt;P&gt;Error in 'where' command: The operator at 'day=BusyHourDay' is invalid.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 10:38:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96314#M24878</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2013-01-23T10:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96315#M24879</link>
      <description>&lt;P&gt;I think you need to add an "AND" between your statements in the &lt;CODE&gt;where&lt;/CODE&gt; command. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where date_hour=BusyHour AND day=BusyHourDay
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Jan 2013 11:02:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96315#M24879</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-01-23T11:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96316#M24880</link>
      <description>&lt;P&gt;Thanks again Ayn.&lt;BR /&gt;
the solution must be close,&lt;BR /&gt;
but the search is now returning 0 results.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 11:22:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96316#M24880</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2013-01-23T11:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96317#M24881</link>
      <description>&lt;P&gt;I think you should break down your search into parts and add one command in the search pipeline at a time, so you can troubleshoot where things go wrong.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jan 2013 14:21:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96317#M24881</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-01-23T14:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96318#M24882</link>
      <description>&lt;P&gt;I've tried a series of combinations but I'm really having trouble with the where clause. Can you point me in the right direction ?&lt;/P&gt;

&lt;P&gt;PS: I've replaced &lt;BR /&gt;
| stats avg(CpuUsedPct) as AvgUsedCpuPct by day, date_hour&lt;BR /&gt;
by &lt;BR /&gt;
| chart avg(CpuUsedPct) as AvgUsedCpuPct over day&lt;/P&gt;</description>
      <pubDate>Thu, 24 Jan 2013 16:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96318#M24882</guid>
      <dc:creator>splunk_zen</dc:creator>
      <dc:date>2013-01-24T16:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: subsearch -  Busy Hour CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96319#M24883</link>
      <description>&lt;P&gt;The thing is that when you've run the &lt;CODE&gt;chart&lt;/CODE&gt; command, the fields you're trying to filter on do not exist anymore. The only fields you have available after the last &lt;CODE&gt;chart&lt;/CODE&gt; command are the ones it produces - AvgUsedPct and day.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Jan 2013 12:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/subsearch-Busy-Hour-CPU-usage/m-p/96319#M24883</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-01-25T12:20:50Z</dc:date>
    </item>
  </channel>
</rss>

