Skip to main content

Introducing the Power BI Activity Log

Headshot of article author Kay Unkroth

We are excited to announce the availability of a new Power BI API called the activity log, which enables Power BI service admins to track user and admin activities within a Power BI tenant. It is comparable to the unified Office 365 audit log in the sense that both logs contain a complete copy of the Power BI auditing data, but there are also several key differences that are particularly important for Power BI service admins, as the following table reveals.

 

Unified Office 365 audit log Power BI activity log
Includes events from SharePoint Online, Exchange Online, Dynamics 365, and other services in addition to the Power BI auditing events. Only includes the Power BI auditing events.
Only users with View-Only Audit Logs or Audit Logs permissions have access, such as global admins and auditors. Global admins and Power BI service admins have access.
Global admins and auditors can search the unified audit log by using Office 365 Security & Compliance Center, the Microsoft 365 Security Center, and the Microsoft 365 Compliance Center. There’s no user interface to search the activity log yet.
Global admins and auditors can download audit log entries by using Office 365 Management APIs and cmdlets. Global admins and Power BI service admins can download activity log entries by using a Power BI REST API and management cmdlet.

 

To distinguish the Power BI-specific log from the unified audit log, Power BI chose the name activity log, but the Power BI auditing data within both logs is identical. In this way, global admins and auditors can continue to use the Security and Compliance Centers for all their auditing needs, while Power BI service admins now have a straightforward way to access and download the data they need to monitor the actions of their users and administrators in their Power BI tenant. You could call the activity log an audit log as well, but different names help to avoid confusion.

So, what can you do with the Power BI activity log? For starters, you can write an administrative application based on the Power BI REST APIs to export the activity events into a blob store or SQL database so that you can build a custom usage report on top of the exported data. In the ActivityEvents REST API call, you must specify a start date and end date and optionally a filter to select activities by activity type or user id.

Because the activity log may possibly contain a large amount of data, the ActivityEvents API currently only supports downloading up to one day of data per request. In other words, the start date and end date must specify the same day, as in the following example. Make sure you specify the DateTime values in ISO 8601 compliant UTC formats.

https://api.powerbi.com/v1.0/myorg/admin/activityevents?startDateTime='2019-08-31T00:00:00'&endDateTime='2019-08-31T23:59:59'

If the number of entries is large, the ActivityEvents API returns only around 5,000 to 10,000 entries and a continuation token. You must then call the ActivityEvents API again with the continuation token to obtain the next batch of entries, and so forth, until you have retrieved all entries and no longer receive a continuation token. The following example shows how to use the continuation token.

https://api.powerbi.com/v1.0/myorg/admin/activityevents?continuationToken=’%2BRID%3ARthsAIwfWGcVAAAAAAAAAA%3D%3D%23RT%3A4%23TRC%3A20%23FPC%3AARUAAAAAAAAAFwAAAAAAAAA%3D’

As a general rule, regardless of the number of entries returned, if the results include a continuation token, make sure you call the API again with that token to retrieve the remaining data, until a continuation token is no longer returned. It can happen that a call even returns a continuation token without any event entries. But don’t let the absence of activity events distract you. Just keep calling back with that continuation token. Here is how you can code against the continuation token that is returned in the response:

while(response.ContinuationToken != null)
{
    // Store the activity event results in a list for example
    completeListOfActivityEvents.AddRange(response.ActivityEventEntities);

    // Make another call to the API with continuation token
    response = GetPowerBIActivityEvents(response.ContinuationToken)
}
completeListOfActivityEvents.AddRange(response.ActivityEventEntities);

It might be easier to download activity events by using the Power BI Management cmdlets for PowerShell, which include a Get-PowerBIActivityEvent cmdlet that handles the continuation token for you automatically. The Get-PowerBIActivityEvent cmdlet takes a StartDateTime and an EndDateTime parameter with the same restrictions as the ActivityEvents REST API, meaning the start date and end date must reference the same date value because you can only retrieve the activity data for one day at a time.

The following screenshot illustrates how to download all Power BI activities in a sample tenant for December 1st. As the results indicate, the script downloaded almost 19,000 entries, which the command then converted from JSON into .NET objects for straightforward access to individual activity properties. The script could now  process each object individually in a foreach loop.

As mentioned, you can filter the activity events by activity type and user id. The following screenshot demonstrates how to download only the events data for the ViewDashboard activity. For additional information about supported parameters, use the command Get-Help Get-PowerBIActivityEvents.

And that’s it for a quick introduction of the Power BI activity log. If you are a Power BI service admin, we hope this feature gives you more visibility across your Power BI tenant and more flexibility to build admin solutions that help increase your productivity. Future improvements might include a user interface for searching the activity log in the Power BI Admin Portal with the capability to download the results into a .csv file as well as additional filtering capabilities in the ActivityEvents REST API and Get-PowerBIActivityEvent cmdlet. So, stay tuned for even more capabilities empowering Power BI service administrators.