<?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 call stats to calculate concurrent calls. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553614#M157188</link>
    <description>&lt;P&gt;You could do something like this to create start and end events for each call, then have a running total of concurrent calls.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| gentimes start=-1 increment=1m 
| rename starttime as _time
| fields _time
| eval CallDurationSecs=random()%1000



| eval starttime=_time-CallDurationSecs
| eval times=mvappend(starttime,_time)
| mvexpand times
| eval _time=times
| eval change=if(_time=starttime,1,-1)
| sort _time
| streamstats sum(change) as concurrentcalls&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 29 May 2021 07:29:04 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-05-29T07:29:04Z</dc:date>
    <item>
      <title>Use call stats to calculate concurrent calls.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553601#M157182</link>
      <description>&lt;P&gt;I have a data source that provides&amp;nbsp; call records for telephone calls. Each call record contains a call duration and timestamp.&lt;/P&gt;&lt;P&gt;I want to perform the follow calculation and graph it.&lt;/P&gt;&lt;P&gt;If i can determine the number calls per minute "A" and the average call duration (in minutes) "B" . Then A*B is the number of circuits in use (concurrent calls, erlangs)&lt;/P&gt;&lt;TABLE width="212"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64"&gt;Call/min&lt;/TD&gt;&lt;TD width="84"&gt;Avg call Min&lt;/TD&gt;&lt;TD width="64"&gt;Circuits&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;211.85&lt;/TD&gt;&lt;TD&gt;3.816666667&lt;/TD&gt;&lt;TD&gt;808.5608&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following works. But it averaged over the hour so if the call rate is not uniform the result is misleading.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="C37996518_0-1622248067910.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14370i4A5C2EB63E48398E/image-size/large?v=v2&amp;amp;px=999" role="button" title="C37996518_0-1622248067910.png" alt="C37996518_0-1622248067910.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 00:29:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553601#M157182</guid>
      <dc:creator>C37996518</dc:creator>
      <dc:date>2021-05-29T00:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Use call stats to calculate concurrent calls.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553609#M157186</link>
      <description>&lt;P&gt;When asking a question, it is best to illustrate sample data (doesn't have to &amp;nbsp;be real), desired output, &amp;nbsp;and trial code if any, all in text. &amp;nbsp;Screenshot is very unhelpful unless it is simple graphs.&lt;/P&gt;&lt;P&gt;Back on topic. Several years ago, I had to solve a slightly more complex concurrency problem, in that in addition to duration, each "event" also has a count. &amp;nbsp;But I can no longer find that answer. &amp;nbsp;Fortunately, I was doing some forensics on my old computer today and found the piece in a dashboard.&lt;/P&gt;&lt;P&gt;Assuming data like the following&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;_time&lt;/TD&gt;&lt;TD&gt;call_id&lt;/TD&gt;&lt;TD&gt;duration&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 21:32:20&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_1&lt;/TD&gt;&lt;TD width="40px"&gt;39&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 21:21:33&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_2&lt;/TD&gt;&lt;TD width="40px"&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 21:15:54&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_3&lt;/TD&gt;&lt;TD width="40px"&gt;29&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 21:07:15&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_4&lt;/TD&gt;&lt;TD width="40px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 20:56:56&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_5&lt;/TD&gt;&lt;TD width="40px"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 20:44:01&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_6&lt;/TD&gt;&lt;TD width="40px"&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 20:38:14&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_7&lt;/TD&gt;&lt;TD width="40px"&gt;37&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 20:19:03&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_8&lt;/TD&gt;&lt;TD width="40px"&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 20:16:36&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_9&lt;/TD&gt;&lt;TD width="40px"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;2021-05-28 20:01:49&lt;/TD&gt;&lt;TD width="64.171875px"&gt;call_10&lt;/TD&gt;&lt;TD width="40px"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="166.046875px"&gt;...&lt;/TD&gt;&lt;TD width="64.171875px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Here, duration is measured &amp;nbsp;in minutes.&lt;/P&gt;&lt;P&gt;The idea is to chop off duration into slices with &amp;nbsp;mvranage(), "convert" those &amp;nbsp;slices into new events with mvexpand, &amp;nbsp;each time-shifted by the slice's offset, then add the events up, like the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval inc = mvrange(0, duration)
| mvexpand inc
| eval _time = _time - inc * 60
| timechart span=1m sum(eval(1)) as concurrent&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here, I assume that time is stamped at the end of call. &amp;nbsp;If timestamp marks the beginning, time shift should use positive offset. &amp;nbsp;For accuracy, the timechart uses 1m timespan, the same amount &amp;nbsp;as unit of duration.&lt;/P&gt;&lt;P&gt;Here is &amp;nbsp;a sample chart: &amp;nbsp;(Total plots the concurrence count.)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="overlapchart.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14371i5DC35FB472D13D9D/image-size/large?v=v2&amp;amp;px=999" role="button" title="overlapchart.png" alt="overlapchart.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It is produced with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=25
| streamstats count
| eval _time = _time - count * 600 + random() % 600, call_id = "call_" . count, duration = random() % 60
| fields - count


| eval inc=mvrange(0, duration)
| mvexpand inc
| eval _time = _time - inc*60
| timechart span=1m limit=30 sum(eval(1)) as concurrent by call_id
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first part simulates randomized sample data. &amp;nbsp;The chart is color striped (with &amp;nbsp;by caller_id) to highlight how call events are sliced up then added together, so addtotals is used to also show totals, and data &amp;nbsp;overlay is used so Total is not mixed into striped area chart. &amp;nbsp;As you are only concerned about total concurrency, there &amp;nbsp;is no need to sum by caller_id.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 06:28:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553609#M157186</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-05-29T06:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Use call stats to calculate concurrent calls.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553611#M157187</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;For accuracy, the timechart uses 1m timespan, the same amount &amp;nbsp;as unit of duration.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Maximum accuracy may not be all that &amp;nbsp;important in all applications. &amp;nbsp;Splunk's standard charts has a limit on granularity and &amp;nbsp;total timespan. &amp;nbsp;Sometimes, you just want to know what is the maximum concurrency in any given timespan. &amp;nbsp;To calculate this, divide time into bins that equal the unit of duration, then use a dedicated stats command before using timechart to calculate maximum (or average, or any &amp;nbsp;other statistics), like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval inc = mvrange(0, duration)
| mvexpand inc
| eval _time = _time - inc * 60
| bin span=1m  _time
| stats sum(eval(1)) as concurrency by _time call_id
| timechart limit=30 max(concurrency) by call_id
| addtotals&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The &amp;nbsp;following plots maximum concurrency in 5-min intervals.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="maxoverlapchart-5m.png" style="width: 999px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/14372i26F932C353FF04EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="maxoverlapchart-5m.png" alt="maxoverlapchart-5m.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 06:51:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553611#M157187</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-05-29T06:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: Use call stats to calculate concurrent calls.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553614#M157188</link>
      <description>&lt;P&gt;You could do something like this to create start and end events for each call, then have a running total of concurrent calls.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| gentimes start=-1 increment=1m 
| rename starttime as _time
| fields _time
| eval CallDurationSecs=random()%1000



| eval starttime=_time-CallDurationSecs
| eval times=mvappend(starttime,_time)
| mvexpand times
| eval _time=times
| eval change=if(_time=starttime,1,-1)
| sort _time
| streamstats sum(change) as concurrentcalls&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 29 May 2021 07:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553614#M157188</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-05-29T07:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Use call stats to calculate concurrent calls.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553626#M157190</link>
      <description>&lt;P&gt;By calculating start time for each event (one value) &lt;EM&gt;before&lt;/EM&gt; mvexpand, thus creating only two events per original event, you solved my biggest performance killer back then. &amp;nbsp;Thank you,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;!&lt;/P&gt;</description>
      <pubDate>Sat, 29 May 2021 15:05:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-call-stats-to-calculate-concurrent-calls/m-p/553626#M157190</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2021-05-29T15:05:42Z</dc:date>
    </item>
  </channel>
</rss>

