Analyze the Power BI Activity Logs

To get insights into your activities of Power BI from your users you have multiple options:
– The Usage Metrics
– The Audit Logs
– … and the Activity Logs

For me fits the last one, because you do not need an Exchange license (you need this for the Audit Logs) and the Metrics App is too graphical and, at least you cannot export the data. To export the data, I have written this PowerShell Script:

Login-PowerBI
# 90 days backwards90..1 |foreach {    $Date = (((Get-Date).Date).AddDays(-$_))    "$Date"
    $StartDate = (Get-Date -Date ($Date) -Format yyyy-MM-ddTHH:mm:ss)    $EndDate = (Get-Date -Date ((($Date).AddDays(1)).AddMilliseconds(-1)) -Format yyyy-MM-ddTHH:mm:ss)        $ActivityLogs = Get-PowerBIActivityEvent -StartDateTime $StartDate -EndDateTime $EndDate | ConvertFrom-Json    $ActivityLogSchema = $ActivityLogs | `    Select-Object Id,RecordType,CreationTime,Operation,OrganizationId,UserType,UserKey,Workload, `        UserId,ClientIP,UserAgent,Activity,ItemName,WorkspaceName,DatasetName,ReportName, `        WorkspaceId,CapacityId,CapacityName,AppName,ObjectId,DatasetId,ReportId,IsSuccess, `        ReportType,RequestId,ActivityId,AppReportId,DistributionMethod,ConsumptionMethod, `        @{Name="RetrieveDate";Expression={$RetrieveDate}}    # Write a file per day     $ActivityLogSchema | Export-Csv c:\temp\audit\PowerBI_AudititLogs-$((($Date).ToUniversalTime()).ToString("yyyyMMddThhmmssZ")).csv
}

This script exports the data of the last 90 days. (Power BI saves only the last 90 days). If you have already exported a single day, the scripts overwrite the existing files which are already exists. In my experience I got sometimes a timeout for some days by exporting. So, I think it is not a good idea to export only after this timeframe and it is better to export every day or week.
After you have exported the logs, you can import the folder into Power BI Desktop on analyze the data like this:

You can also implement an Azure Function and write the files into a Blob storage. With this solution you can automate the export and create an automatic refresh of your Power BI report at the service.

Categorized: Allgemein

Comments are closed.