Get Current MAUs (Monthly Active Users)
Problem#
The system log API can be utilized to create virtually any report, however, it can be complicated to get started. A common problem is determining your existing MAUs (monthly active users).
Note: on a One App or Enterprise plan, you can get this report from your Okta contact
Solution#
To get the current month active users, make a request to the system log API with a filter (eventType eq "user.session.start") to only display events of when users have successfully created a session. In addition, set the parameters since and until to the first and end of the month in the UTC timezone.
Afterwards, track which users have logged in for the month and calculate the total.
The solution can be seen in the reference scripts listed below.
Node.js v10.0.0 or higher#
Make sure to install the @okta/okta-sdk-nodejs package: npm install @okta/okta-sdk-nodejs
Try it Yourself#
You can run the sample script below to test the code for your own instances, simply update the secrets API_TOKEN and ORG_URL with your values.
Python 3.6.0 or higher#
Install the Okta SDK: pip install okta
Try it Yourself#
You can run the sample script below to test the code for your own instances, simply update the secrets API_TOKEN and ORG_URL with your values.
Discussion#
It's possible to recreate these solution using the native HTTP module, but the recipes provided utilize the Okta SDKs to simplify the nuances of handling rate-limits and pagination with the API.
In addition, these solutions can be extend to derive other meaningful things such as the most active user, least active user, etc.
Credits#
Credits to Jay Venkatraj for proposing this problem to the CIAM community and Brandon Him for the initial recipe.
Feel free to contribute support for other languages by submitting a PR.