Forum Discussion
Usage Metric Report(Organization lvl)
- 10 months ago
Hi PowerBiLearner4 ,
Thanks for the update.
With the permissions that you currently have, it’s not possible to get organization-level usage metrics for 17 workspaces over 120 days. Without tenant admin approval for the Power BI Admin APIs, you can only access workspace-level usage reports, and those don’t provide 120 day history. To get the full 120 day, tenant-wide usage data, admin access or a service principal enabled for admin APIs is required. Once the permission is granted, the extraction can be fully automated.Thank you.
Do you have the steps you followed with you?
Hi PowerBiLearner4,
I am using a custom python script to pull the audit data.
This is the function that pulls data:
def query_powerbi_audit(start_datetime, end_datetime, filter_query=None):
headers = {
'Authorization': f'Bearer {get_access_token()}',
'Content-Type': 'application/json'
}
params = {
'startDateTime': f'\'{start_datetime}\'',
'endDateTime': f'\'{end_datetime}\'',
}
if filter_query:
params['$filter'] = filter_query
all_events = {
"activityEventEntities": [],
}
# Start with the initial API URL for the first request. This will be updated in the loop below.
current_url = API_URL
while True:
# Send the request
response = requests.get(current_url, headers=headers, params=params)
response.raise_for_status() # Raises an error for bad responses (4xx or 5xx)
# Parse the response
data = response.json()
all_events["activityEventEntities"].extend(data.get("activityEventEntities", []))
# Check if there's more data to fetch
if data.get("lastResultSet"):
break # If lastResultSet is true, we are done
# Update the URL for the next request using continuationUri
current_url = data.get("continuationUri")
if not current_url:
break # If there's no continuationUri, we are done
# Clear params for the next request
params = {} # Reset params for the next request
return all_eventsIf you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
- PowerBiLearner411 months agoFrequent Visitor
Sorry For the late reply i had issue with the login into the id
i registered an app on azure portal with the following permission is this enough for the above steps ?