Power BI etkinlik günlüğüne erişme
Bu makale, Power BI etkinlik günlüğüne erişmesi gereken Power BI yöneticileri için hazırlanmıştır. Etkinlik günlüğünü aramaya yönelik bir kullanıcı arabirimi henüz olmadığından, Power BI REST API ve yönetim cmdlet’lerini kullanmanız gerekir.
Not
Bu makalede, Power BI etkinlik günlüğü tanıtılmamakta veya açıklanmamaktadır. Daha fazla bilgi için bkz. Power BI'da kullanıcı etkinliklerini izleme.
PowerShell örneği
Power BI etkinlik günlüğü olaylarının nasıl filtreleneceği ve alınacağı hakkında bilgi edinmenize yardımcı olması için bir Power BI örneği sağlanmıştır. Tüm kod parçaları ve senaryolara, nasıl yapılır yönergeleri ve izlenecek genel boşluklar veya sorunlar ek açıklama olarak eklenmiştir. İki senaryo ele alınmaktadır:
- Belirli bir uygulama için kullanıcıların listesini alma.
- Doğrudan rapor paylaşımı için kullanıcıların listesini alma.
Not
Power BI Yönetici API’si ve Power BI PowerShell modülleri hakkında temel bilgi sahibi olmanız gerekir. Bu betik blokları yürütülmeden önce PowerShell modülleri yüklenmiş olmalıdır. Daha fazla bilgi için bkz. Power BI'da kullanıcı etkinliklerini izleme.
Power BI olaylarının alınmasında 30 dakikaya kadar bir gecikme olabilir.
Örneği kullanmak için aşağıdaki gereksinimleri karşılamanız gerekir:
- Power BI PowerShell modüllerini yükleyin.
- PowerShell betiğinin kullanıcısı, Connect-PowerBIServiceAccount cmdlet’ini kullanarak oturum açmalı ve istendiğinde Power BI yöneticisi kimlik bilgilerini girmelidir. Etkinlik Günlüğü API’sini kullanmak için yönetici ayrıcalıkları gerekir.
Önemli
Yönetici ayrıcalıklarına sahip olmayan kullanıcılar, örnek betikteki kod parçalarını yürütemez.
# Written by Sergei Gundorov; v1 development started on 07/08/2020
#
# Intent: 1. Address common friction points and usage issues and questions related to the
# events generated by Power BI Service that are stored in the activity log.
# 2. Provide boiler plate code for capturing all 30 days of available data.
# 3. Power BI admin privileges are required to use the Activity Log API.
#
# Use: Sign in to the Power BI service with admin privileges and execute specific segment one at a time.
# IMPORTANT: Use Connect-PowerBIServiceAccount to connect to the service before running individual code segments.
# IMPORTANT: $day value may need to be adjusted depending on where you're located in the world relative to UTC.
# The Power BI activity log records events using UTC time; so add or subtract days according to your global location.
# SCENARIO: Sample code fragment to retrieve a limited number of attributes for specific events for specific user report viewing activity.
# You need to get user's Azure Active Directory (AAD) object ID. You can use this Azure AD cmdlet: https://docs.microsoft.com/powershell/module/azuread/get-azureaduser?view=azureadps-2.0
# Dates need to be entered using ISO 8601 format; adjust dates to span no more than 24 hours.
$a=Get-PowerBIActivityEvent -StartDateTime '2020-06-23T19:00:00.000' -EndDateTime '2020-06-23T20:59:59.999' -ActivityType 'ViewReport' -User [USER AAD ObjectId GUID] | ConvertFrom-Json
# You can use any attribute value to filter results further. For example, a specific event request Id can be used to analyze just one specific event.
$a | Select RequestId, ReportName, WorkspaceName |where {($_.RequestId -eq '[RequestId GUID of the event]')}
# SCENARIO: Retrieve a list of users for specific app.
# The user list can be partially derived (based on last 30 days of available activity) by combining data for two events: CreateApp and UpdateApp.
# Both events will contain OrgAppPermission property that contains app user access list.
# Actual app installation can be tracked using InstallApp activity.
# Run each code segment separately for each event.
# Iterate through 30 days of activity CreateApp.
$day=Get-date
for($s=0; $s -le 30; $s++)
{
$periodStart=$day.AddDays(-$s)
$base=$periodStart.ToString("yyyy-MM-dd")
write-host $base
$a=Get-PowerBIActivityEvent -StartDateTime ($base+'T00:00:00.000') -EndDateTime ($base+'T23:59:59.999') -ActivityType 'CreateApp' -ResultType JsonString | ConvertFrom-Json
$c=$a.Count
for($i=0 ; $i -lt $c; $i++)
{
$r=$a[$i]
Write-Host "App Name `t: $($r.ItemName)"
` "WS Name `t: $($r.WorkSpaceName)"
` "WS ID `t`t: $($r.WorkspaceId)"
` "Created `t: $($r.CreationTime)"
` "Users `t`t: $($r.OrgAppPermission) `n"
}
}
# Iterate through 30 days of activity UpdateApp.
$day=Get-date
for($s=0; $s -le 30; $s++)
{
$periodStart=$day.AddDays(-$s)
$base=$periodStart.ToString("yyyy-MM-dd")
write-host $base
$a=Get-PowerBIActivityEvent -StartDateTime ($base+'T00:00:00.000') -EndDateTime ($base+'T23:59:59.999') -ActivityType 'UpdateApp' -ResultType JsonString | ConvertFrom-Json
$c=$a.Count
for($i=0 ; $i -lt $c; $i++)
{
$r=$a[$i]
Write-Host "App Name `t: $($r.ItemName)"
` "WS Name `t: $($r.WorkSpaceName)"
` "WS ID `t`t: $($r.WorkspaceId)"
` "Updated `t: $($r.CreationTime)"
` "Users `t`t: $($r.OrgAppPermission) `n"
}
}
# Iterate through 30 days of activity InstallApp.
$day=Get-date
for($s=0; $s -le 30; $s++)
{
$periodStart=$day.AddDays(-$s)
$base=$periodStart.ToString("yyyy-MM-dd")
write-host $base
$a=Get-PowerBIActivityEvent -StartDateTime ($base+'T00:00:00.000') -EndDateTime ($base+'T23:59:59.999') -ActivityType 'InstallApp' -ResultType JsonString | ConvertFrom-Json
$c=$a.Count
for($i=0 ; $i -lt $c; $i++)
{
$r=$a[$i]
Write-Host "App Name `t: $($r.ItemName)"
` "Installed `t: $($r.CreationTime)"
` "User `t`t: $($r.UserId) `n"
}
}
# SCENARIO: Retrieve a list of users for direct report sharing.
# This logic and flow can be used for tracing direct dashboard sharing by substituting activity type.
# Default output is formatted to return the list of users as a string. There is commented out code block to get multi-line user list.
# IMPORTANT: Removal of a user or group from direct sharing access list event is not tracked. For this reason, the list may be not accurate.
# IMPORTANT: If the user list contains a GUID instead of a UPN the report was shared to a group.
# Group name and email can be obtained using Azure AD cmdlets using captured ObjectId GUID.
# Iterate through 30 days of activity ShareReport.
$day=Get-date
for($s=0; $s -le 30; $s++)
{
$periodStart=$day.AddDays(-$s)
$base=$periodStart.ToString("yyyy-MM-dd")
#write-host $base
$a=Get-PowerBIActivityEvent -StartDateTime ($base+'T00:00:00.000') -EndDateTime ($base+'T23:59:59.999') -ActivityType 'ShareReport' -ResultType JsonString | ConvertFrom-Json
$c=$a.Count
for($i=0 ; $i -lt $c; $i++)
{
$r=$a[$i]
Write-Host "Rpt Name `t: $($r.ItemName)"
` "Rpt Id `t: $($r.ArtifactId)"
` "WS Name `t: $($r.WorkSpaceName)"
` "WS ID `t`t: $($r.WorkspaceId)"
` "Capacity `t: $($r.CapacityId)"
` "SharedOn `t: $($r.CreationTime.Replace('T',' ').Replace('Z',''))"
` "User `t`t: $($r.UserId)"
# NOTE: $_.RecipientEmail + $_.RecipientName or +$_.ObjectId is the case for group sharing
# can never happen both at the same time in the same JSON record
` "Shared with`t: $(($r.SharingInformation)| % {$_.RecipientEmail + $_.ObjectId +'[' + $_.ResharePermission +']'})"
#OPTIONAL: Formatted output for SharingInformation attribute
#$sc= $r.SharingInformation.Count
#Write-Host "Shared with`t:"
#for($j=0;$j -lt $sc;$j++)
#{
# Write-Host "`t`t`t $($r.SharingInformation[$j].RecipientEmail)" -NoNewline
# Write-Host $r.SharingInformation[$j].ObjectId -NoNewline
# Write-Host ('[' + $r.SharingInformation[$j].ResharePermission +']')
#}
Write-host ""
}
}
Sonraki adımlar
Bu makaleyle ilgili daha fazla bilgi için aşağıdaki kaynaklara bakın:
- Power BI'da kullanıcı etkinliklerini izleme
- Sorularınız mı var? Power BI Topluluğu'na sorun
- Önerileriniz mi var? Power BI'ı geliştirmek için fikirlerinizi paylaşın