<?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: Question on Search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47050#M11236</link>
    <description>&lt;P&gt;You had the right idea, but you can do a few things to simplify / make your search more efficient:&lt;/P&gt;

&lt;P&gt;1) you don't need a bucket and stats separately. You can simply use a timechart command&lt;BR /&gt;
2) you can perform both calculations in the same stats or timechart command instead of an appendcols&lt;BR /&gt;
3) I've added to the timechart to group by device&lt;/P&gt;

&lt;P&gt;It should look something like this:&lt;/P&gt;

&lt;P&gt;searchPart1 | timechart span=1h sum(SessionCount) as ActiveSessions max(Capacity) as MaxCapacity by device | eval Available = MaxCapacity - ActiveSessions | fields _time device ActiveSessions MaxCapacity&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
    <pubDate>Tue, 28 May 2013 20:37:02 GMT</pubDate>
    <dc:creator>aholzer</dc:creator>
    <dc:date>2013-05-28T20:37:02Z</dc:date>
    <item>
      <title>Question on Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47048#M11234</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;We have devices which maintains session information of various users. These devices have a max capacity of sessions. The device pumps logs as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time       User  SessionCount Device
10 AM       A     3            D1
10 AM       B     4            D1
11 AM       A     10           D1
11:30 AM    A     3            D1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Our summarization happens once in an hour. During summarization the Capacity value is also added to maintain the history. Our Summarization index looks like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    Time       User  SessionCount Device Capacity
    10 AM       A     3            D1    30
    10 AM       B     4            D1    30
    11 AM       A     13           D1    30
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now, i need to display a chart over time with SessionCount and Available Capacity(Capacity - SessionCount).&lt;/P&gt;

&lt;P&gt;We have a device pulldown with default value as All. In this case in search query Device="*" will be there. If Device is chosen then it will be, Say Device="D1"&lt;/P&gt;

&lt;P&gt;For me to display the chart properly, the Capacity should be summed at unique devices alone. It should not be summed up across events then the capacity will be summed up for same device.&lt;/P&gt;

&lt;P&gt;How will i write search, so that i get the resultset as:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Time   SessionCount  Available
10AM   7             23
11AM   13            17
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However i try, i am not getting the desired output.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;

&lt;P&gt;Strive&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2013 08:56:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47048#M11234</guid>
      <dc:creator>strive</dc:creator>
      <dc:date>2013-05-28T08:56:19Z</dc:date>
    </item>
    <item>
      <title>Re: Question on Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47049#M11235</link>
      <description>&lt;P&gt;I did this&lt;/P&gt;

&lt;P&gt;searchPart1 | bucket _time span=1h | stats sum(SessionCount) as TotalSession by _time | appendcols [searchpart1 | bucket _time span=1h | dedup Device _time | stats sum(Capacity) as Available by _time] | eval AvCap = (Available - TotalSession) |fields TotalSession AvCap&lt;/P&gt;

&lt;P&gt;Is there better way to achieve than what i have done&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2013 09:33:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47049#M11235</guid>
      <dc:creator>strive</dc:creator>
      <dc:date>2013-05-28T09:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Question on Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47050#M11236</link>
      <description>&lt;P&gt;You had the right idea, but you can do a few things to simplify / make your search more efficient:&lt;/P&gt;

&lt;P&gt;1) you don't need a bucket and stats separately. You can simply use a timechart command&lt;BR /&gt;
2) you can perform both calculations in the same stats or timechart command instead of an appendcols&lt;BR /&gt;
3) I've added to the timechart to group by device&lt;/P&gt;

&lt;P&gt;It should look something like this:&lt;/P&gt;

&lt;P&gt;searchPart1 | timechart span=1h sum(SessionCount) as ActiveSessions max(Capacity) as MaxCapacity by device | eval Available = MaxCapacity - ActiveSessions | fields _time device ActiveSessions MaxCapacity&lt;/P&gt;

&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2013 20:37:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47050#M11236</guid>
      <dc:creator>aholzer</dc:creator>
      <dc:date>2013-05-28T20:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Question on Search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47051#M11237</link>
      <description>&lt;P&gt;You can probably save some compute cycles with a different search. Let's assume that you have the Device and Time fields available as part of your summary. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  index="summary" sourcetype="my_summary_data" 
| stats sum(SessionCount) AS  SessionCount values(Capacity) AS Capacity by Device Time 
| eval Available=Capacity-SessionCount
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That will likely provide you a result like this:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/Untitled105.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;I hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2013 20:40:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Question-on-Search/m-p/47051#M11237</guid>
      <dc:creator>Gilberto_Castil</dc:creator>
      <dc:date>2013-05-28T20:40:14Z</dc:date>
    </item>
  </channel>
</rss>

