<?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: Use subsearch for timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231017#M68522</link>
    <description>&lt;P&gt;Why are you using subsearches? Does the following come close to what you're trying to achieve?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=lync_scs source="WinEventLog:Lync Server" (EventCode=4410 OR EventCode=41113) | timechart span=1d count by EventCode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
    <pubDate>Wed, 17 Aug 2016 09:35:34 GMT</pubDate>
    <dc:creator>davebrooking</dc:creator>
    <dc:date>2016-08-17T09:35:34Z</dc:date>
    <item>
      <title>Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231015#M68520</link>
      <description>&lt;P&gt;I want to use two evals with subsearches. In the subsearches I would like to use a timechart to count the number of event per day.&lt;BR /&gt;
At the end, I want to use a third timechart and display the two generated variables.&lt;BR /&gt;
My code looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=lync_scs source="WinEventLog:Lync Server" | eval id_one = [ search index=lync_scs source="WinEventLog:Lync Server" EventCode=4410 | timechart span=1d count as id_one] | eval id_two = [ search index=lync_scs source="WinEventLog:Lync Server" EventCode=41113 | timechart span=1d count as id_two] | timechart span=1d values(id*)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately, my search doesnt work.&lt;BR /&gt;
Could you help me please? Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 08:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231015#M68520</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2016-08-17T08:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231016#M68521</link>
      <description>&lt;P&gt;I forgot the return $id_one and return $id_two after the timechart in the evals&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:39:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231016#M68521</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2020-09-29T10:39:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231017#M68522</link>
      <description>&lt;P&gt;Why are you using subsearches? Does the following come close to what you're trying to achieve?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=lync_scs source="WinEventLog:Lync Server" (EventCode=4410 OR EventCode=41113) | timechart span=1d count by EventCode
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 09:35:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231017#M68522</guid>
      <dc:creator>davebrooking</dc:creator>
      <dc:date>2016-08-17T09:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231018#M68523</link>
      <description>&lt;P&gt;I used the code as an example. &lt;BR /&gt;
This is my original search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testindex (host=server1 OR host=server2) sourcetype=WinEventLog:Application  | eval sla=99.9 | eval not_available = [search index=testindex (host=server1 OR host=server2) sourcetype=WinEventLog:Application  EventCode=700 OR Eventcode=702 | timechart span=1d count as not_available | return $not_available] | eval available = [search index=testindex (host=server1 OR host=server2) sourcetype=WinEventLog:Application  EventCode!=700 OR Eventcode!=702 | timechart span=1d count as available | return $available] | eval sla2 = 100 - (not_available / available) | timechart span=1d values(*available)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do you know another way?&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 09:42:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231018#M68523</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2016-08-17T09:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231019#M68524</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;I haven't tested this, but could you use something like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testindex (host=server1 OR host=server2) sourcetype=WinEventLog:Application  | 
eval not_available=if(EventCode=700 OR EventCode=702,1,0) |
eval available=if(EventCode!=700 OR EventCode!=702,1,0) |
timechart span=1d sum(available) as available sum(not_available) as not_available
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can also use eval functions within stats/chart/timechart commands, as shown in the &lt;A href="https://docs.splunk.com/Documentation/Splunk/6.4.2/Search/Usestatswithevalexpressionsandfunctions"&gt;Search Manual&lt;/A&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    index=testindex (host=server1 OR host=server2) sourcetype=WinEventLog:Application  | 
    timechart span=1d sum(eval(if(EventCode!=700 OR EventCode!=702,1,0))) as available sum(eval(if(EventCode=700 OR EventCode=702,1,0))) as not_available
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 10:12:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231019#M68524</guid>
      <dc:creator>davebrooking</dc:creator>
      <dc:date>2016-08-17T10:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231020#M68525</link>
      <description>&lt;P&gt;Thanks a lot! So I have the following search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=testindex (host=server1 OR host=server2) sourcetype=WinEventLog:Application |
 eval not_available=if(EventCode=700 OR EventCode=702,1,0) |
 eval available=if(EventCode!=700 OR EventCode!=702,1,0) | timechart span=1d sum(available) as available_time, sum(not_available) as not_available_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I need one field more.&lt;BR /&gt;
This field is calculated like this:&lt;/P&gt;

&lt;P&gt;eval sla = 100 - (not_available_time / available_time)^&lt;/P&gt;

&lt;P&gt;Do you know, how can I include this in the timechart?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:39:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231020#M68525</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2020-09-29T10:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use subsearch for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231021#M68526</link>
      <description>&lt;P&gt;Just add &lt;CODE&gt;eval sla = 100 - (not_available_time / available_time)&lt;/CODE&gt; to the end of your query.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Aug 2016 10:55:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-subsearch-for-timechart/m-p/231021#M68526</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-08-17T10:55:49Z</dc:date>
    </item>
  </channel>
</rss>

