# How to implement total subscribed minutes of a Session

**URL:** <https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908>\
**Category:** How to implement?\
**Tags:** v2\
**Created:** [August 26, 2020, 6:46am UTC](https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908 "2020-08-26T06:46:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [August 26, 2020, 6:46am UTC](https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908/1 "2020-08-26T06:46:06Z")

</div>

Hi,  
**I have a requirement to calculate the total subscribed minutes of a session**.

For e.g. If a session has 2 subscribers(User-1 and User-2) and they consumed the stream for 5 minutes and 10 minutes respectively then  
**Total Subscribed minutes of the Session would be = Total minutes subscribed by User-1 + Total Minutes subscribed by User-2**

I can handle this independently on my APP using user connect and disconnect event, but i want to make it the part of Openvidu Inspector or Openvidu Kibana dashboard.

While exploring the **Inspector** panel i found a section **“History”** where it seems showing the same set of data which i need but i am confused how the calculation is being done. I am attaching the screen shot and please describe how the calculation is being done for  
**"Total Users"** , **“Total Connections”** , **“Total Publisher”** , **“Total Subscribers”** , **"Streamed Time"**

 ![History](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/d12d8fccc319e8ff602ea4aeda24905b9e9f2c69.png)  
**For your information,**

- I had only 1 Publisher and 4 subscriber in this session but it’s showing 4 Publisher and 19 subscribers.
- Each users (Publisher and Subscribers) was getting connected and disconnected multiple times. I don’t know the exact number of times they connected and disconnected but it would be approx 3-4 times each.
- Session started at 11:26 and ended at 11:31 which is total 15 Minutes but in History section it’s showing 25 Mints. It may be because we have set 10 minutes times to auto stop the recording that why it seems showing total Duration = 25 Mints

**Please help to understand the calculation of each field mentioned above.**

**If i need to achieve the same thing from Kibana how can i achieve it?**

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [August 26, 2020, 8:51am UTC](https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908/2 "2020-08-26T08:51:12Z")

</div>

> Each users (Publisher and Subscribers) was getting connected and disconnected multiple times.

There you have the reason why you get 4 publishers per userand 19 subscribers. Each stream represents a single Publisher or Subscriber since it is created until it is destroyed. If a user creates and destroys multiple entities, they will show up as different Publishers or Subscribers.

To implement your own visualizations in Kibana, just take a look to this documentation: [OpenVidu Docs](https://docs.openvidu.io/en/2.15.0/openvidu-pro/detailed-session-monitoring/#creating-your-own-visualizations-and-dashboards)

You can make use of the **`xxxxSummary`** Elasticsearch documents to get all of the information shown by OpenVidu Inspector in the History page (in fact, OpenVidu Inspector gets it from these very same events).

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [August 26, 2020, 9:09am UTC](https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908/3 "2020-08-26T09:09:50Z")

</div>

Thanks @pabloFuente for the information,  
Can you please confirm one thing **Streamed Time** showing in History section - Is it the total duration of every subscribers connected in the session? Or every subscribers + every publishers both is considered.

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [August 26, 2020, 9:30am UTC](https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908/4 "2020-08-26T09:30:41Z")

</div>

Streamed time as shwon by the History page is the addition of all Publishers and Subscribers duration.  
For example, this user’s Connection to a session:

 ![image](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/e823d35848e1f4505d2594d207a7acaf34085c58.png)

In total has 17:20 + 17:02 + 00:11 = 34:33 streamed time

---

<div class="post-metadata">

**Author:** ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)\
**Post date:** [August 26, 2020, 9:55am UTC](https://openvidu.discourse.group/t/how-to-implement-total-subscribed-minutes-of-a-session/1908/5 "2020-08-26T09:55:14Z")

</div>

Thanks @pabloFuente for the clarification.
