MongoDB Aggregation Framework inside Countly
-
Upload
countly -
Category
Data & Analytics
-
view
200 -
download
1
Transcript of MongoDB Aggregation Framework inside Countly
![Page 1: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/1.jpg)
1
MongoDB Aggregation in Countly
![Page 2: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/2.jpg)
Agenda
web: count.ly twitter: @gocountly 2
1. MongoDB aggregation framework
overview
2. Short Countly overview3. Two real scenarios where aggregation
framework is used in CountlyWaiter Zen
Software Developer @Countly
![Page 3: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/3.jpg)
MongoDB Aggregation
web: count.ly twitter: @gocountly 3
• MongoDB Aggregation is a framework designed to process data in a declarative and native way using a powerful yet easy to use interface.
• Documents enter a multi-stage pipeline that transforms the documents into an aggregated result.
• As of MongoDB 3.2 there are 80+ operators that can be used within the aggregation pipeline.
![Page 4: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/4.jpg)
Aggregation Pipeline
web: count.ly twitter: @gocountly 4
![Page 5: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/5.jpg)
Countly
web: count.ly twitter: @gocountly 5
• Countly is an analytics and marketing platform for mobile and web.
• Countly processes more than 50 billion data points monthly.• Countly relies heavily on MongoDB and aggregation framework
for data processing and reporting.
![Page 6: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/6.jpg)
Aggregation in Countly
web: count.ly twitter: @gocountly 6
Countly SDK sends data over to Countly Server. Server stores this information in MongoDB individually for each data point. Aggregation framework is used to produce reports for selected view, date and applied filters.
Countly SDK
Aggregation
![Page 7: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/7.jpg)
Example 1: Daily user sessions
web: count.ly twitter: @gocountly 7
Below example data set lists 6 sessions from users a, b, c and d.
ts: timestampdid: device idup: user properties
![Page 8: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/8.jpg)
Example 1: Daily user sessions
web: count.ly twitter: @gocountly 8
Querying number of users and sessions per each day:
Result:
![Page 9: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/9.jpg)
Example 1: Daily user sessions
web: count.ly twitter: @gocountly 9
Pipeline steps:
1. Group all dates, add device ids to an array and count each document as a session2. Use $size to get the length of the device id array which gives us unique user count
per day3. Sort results based on date
![Page 10: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/10.jpg)
Example 1: Daily user sessions
web: count.ly twitter: @gocountly 10
![Page 11: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/11.jpg)
Example 2: Breakdown of user devices in China
web: count.ly twitter: @gocountly 11
Below example data set lists 6 sessions from users a, b, c and d. (Same dataset as Example 1)
ts: timestampdid: device idup: user properties
![Page 12: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/12.jpg)
Example 2: Breakdown of user devices in China
web: count.ly twitter: @gocountly 12
Querying number of users and sessions per each unique device for users from China:
Result:
![Page 13: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/13.jpg)
Example 2: Breakdown of user devices in China
web: count.ly twitter: @gocountly 13
Pipeline steps:
1. Use $match operator to filter all sessions from China2. Group all devices, add device ids to an array and count each document as a session3. Use $size to get the length of the device id array which gives us unique user count
per device
![Page 14: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/14.jpg)
Example 2: Breakdown of user devices in China
web: count.ly twitter: @gocountly 14
![Page 15: MongoDB Aggregation Framework inside Countly](https://reader030.fdocuments.us/reader030/viewer/2022021502/587e69291a28ab2a538b797b/html5/thumbnails/15.jpg)
Questions?https://count.ly
15