如何批量获取多仪表板的usage metrics(浏览次数)并动态生成报告
Hey there! Totally feel your pain—manual checking of usage metrics (like view counts) for dozens of dashboards is such a time-suck and leaves room for mistakes. Here are some practical, dynamic approaches to solve this:
1. Use Your BI Platform's REST API (Most Flexible Option)
Nearly all modern BI tools (Tableau, Power BI, Looker, etc.) expose a REST API that lets you pull usage data programmatically. This is the most scalable way if you have a lot of dashboards.
For example, if you're using Tableau, you could write a quick Python script to loop through your dashboard IDs and fetch view counts:
import requests import pandas as pd # Configure your server details and auth base_url = "https://your-tableau-server.com/api/3.20" auth_token = "your-auth-token" site_id = "your-site-id" dashboard_ids = ["dash-id-1", "dash-id-2", "dash-id-3"] # List all your dash IDs usage_data = [] headers = {"X-Tableau-Auth": auth_token} for dash_id in dashboard_ids: # Fetch view metrics for the dashboard endpoint = f"{base_url}/sites/{site_id}/views?filter=dashboardId:eq:{dash_id}" response = requests.get(endpoint, headers=headers) views = response.json()["views"]["view"] for view in views: usage_data.append({ "dashboard_id": dash_id, "dashboard_name": view["name"], "total_views": view["viewCount"] }) # Convert to DataFrame and export to CSV/Excel for your report df = pd.DataFrame(usage_data) df.to_excel("dashboard_usage_report.xlsx", index=False)
Just adapt this to your tool's specific API endpoints—check their official docs for exact payloads and auth methods.
2. Use Command-Line Tools (No Coding Required for Basic Tasks)
If you're not into writing scripts, many tools have CLI tools that let you bulk export metrics. For example:
- Power BI: Use the
pbiclitool to pull workspace usage data and filter for dashboards. - Looker: Use the
lookerCLI with commands likelooker usage dashboardto export metrics in bulk.
You can wrap these commands in a shell/PowerShell script to automate the export and even pipe the output straight into your report file.
3. Use Built-in Admin Reporting Features
Don't overlook your platform's native admin tools! Most BI platforms have built-in reports that show usage across all content:
- Tableau Server: Go to the Site Usage report under Admin > Reports, and you can export a CSV with all dashboard view counts.
- Power BI: In the Admin Portal, navigate to Usage metrics > Dashboards and export the full dataset.
- Looker: Use the System Activity dashboard to filter and export dashboard usage data.
This is the quickest option if your tool supports it—no code needed, just a few clicks to get a bulk export.
4. Automate the Pipeline to Your Report
Once you have the bulk data, you can automate feeding it into your report:
- If your report is in Excel/Google Sheets: Use pandas (Python) or Google Sheets API to write the data directly into your report tab.
- If it's another BI dashboard: Set up a scheduled refresh to pull the exported usage data into your report dashboard automatically.
Pro Tips
- Always test with a small set of dashboards first before running a full bulk request.
- Handle API pagination—many APIs return data in chunks, so you'll need to loop through pages if you have hundreds of dashboards.
- Schedule your script/export to run automatically (using cron on Linux, Task Scheduler on Windows) so your report stays up-to-date without manual work.
Hope one of these methods works for you—let me know if you need help adapting it to your specific BI tool!
内容的提问来源于stack exchange,提问作者SREEKAR

