@@ -63,27 +63,47 @@ a timestamp (`ts`), the `uuid` of the meeting, the reuseable external `meeting_i
6363was used to create the meeting, the owning tenant (`tenant_fk `), and three metric values
6464named `users `, `voice ` and `video `.
6565
66- Here is an (untested) example PostgreSQL query returning some useful aggregations. It
67- fetches all rows in a certain time range, calculates min/max/avg values per meeting
68- (per `uuid `), then groups those together by `tenant_fk ` to get meaningfull aggregated
69- values per tenant:
66+ The timestamp (`ts `) will be the exact same for all measurements taken during a single
67+ poll interval. It marks the start of the poll interval, not the exact time of an
68+ individual measurement. This is is done on purpose so you can group by the timestamp to
69+ get a consistend view of the entire cluster at a specific time.
70+
71+ Here is an example that calculates user counts for the entire cluster over time.
72+ It uses the fact mentioned above that all measurements taken during a single poll interval
73+ will have the exact same timestamp.
74+
75+ .. code :: sql
76+
77+ SELECT
78+ ts,
79+ COUNT(*) as meetings,
80+ SUM(users) AS users
81+ FROM meeting_stats
82+ GROUP BY ts
83+ ORDER BY ts
84+
85+ Here is a more complex PostgreSQL example. It fetches all rows in a certain time range,
86+ calculates min/max/avg values per meeting (per `uuid `), then groups those together by
87+ `tenant_fk ` to get meaningfull aggregated values per tenant.
7088
7189.. code :: sql
7290
7391 SELECT
74- tenants.name,
92+ tenants.name AS tenant,
93+ /* Number of meetings */
94+ COUNT(*) AS meetings,
7595 /* Total number of meeting minutes spent by all users combined */
76- SUM(users_avg * EXTRACT(epoch FROM duration)) / 60,
96+ SUM(users_avg * EXTRACT(epoch FROM duration)) / 60 AS meeting_minutes ,
7797 /* Average meeting duration in minutes */
78- AVG(EXTRACT(epoch FROM duration)) / 60,
98+ AVG(EXTRACT(epoch FROM duration)) / 60 AS duration_avg ,
7999 /* Aveage meeting size */
80- AVG(users_avg),
100+ AVG(users_avg) AS users_avg ,
81101 /* Maximum meeting size */
82- MAX(users_max),
102+ MAX(users_max) AS users_max,
103+ /* Number of meetings with more than 25 users peak */
104+ COUNT(CASE WHEN users_max > 100 THEN 1 END) AS large_25,
83105 /* Number of meetings with more than 100 users peak */
84- COUNT(CASE WHEN users_max > 100 THEN 1 END),
85- /* Number of meetings */
86- COUNT(*)
106+ COUNT(CASE WHEN users_max > 100 THEN 1 END) AS large_100
87107 FROM (
88108 SELECT
89109 tenant_fk,
0 commit comments