With the release of the GitHub Copilot Metrics API many teams are looking to leverage this data to help monitor usage against their KPIs. For some, the Copilot Metrics Viewer (github-copilot-resources/copilot-metrics-viewer) might be a great option.
However, many organizations that we work with already have established Power BI teams. If your organization is already using Power BI, please read on!
Located in the ./samples
directory you'll find sample JSON and PBIX files used to create the dashboard below.
Note: This example provided a proof of concept for loading metrics data and requires an exported JSON file. If you have access to the REST API you can configure the Source accordingly.
- Download and open the sample
GitHub Copilot - Telemetry Sample (DM).pbix
file. - The file contains three data sources on the right hand side.
Name | Description |
---|---|
GH Copilot - Details | Detailed breakdown of metrics data by language and editor. |
GH Copilot - Summary | Daily summary of metrics data. |
Last Refresh | Used to display the data time of data refresh on the top-right corner of the dashboard. |
- Open the Power Query Editor by right clicking the
GH Copilot - Details
and selecting Edit query. - Modify the Source step by clicking the settings icon, selecting your JSON file and clicking OK.
- Repeat steps 3 and 4 for the
GH Copilot - Summary
Source. - Click Close and Apply in the top-left of the Power Query Editor.
- On the Report View page click Refresh to load the new data into your dashboard.
- Happy Customizing!
Notes: The REST API provides metrics for the previous 28 days and is refreshed daily with data from the previous day. This is currently in beta, so please ensure you are using the latest version of the REST API.
In order to connect we'll need to generate a token and link to your metrics data:
- Download and open the sample
GitHub Copilot - Telemetry Sample (DM).pbix
file. - Determine if you'll be using the
Enterprise
orOrganization
URL. - Follow the instructions below to generate a token with permissions to access the API: REST API endpoints for GitHub Copilot usage metrics - GitHub Docs
IMPORTANT: Do not share this token and ensure you follow you organizations security policies.
- Open the Power Query Editor by right clicking the
GH Copilot - Details
and selecting Edit query. - Select Advanced editor.
- Replace the first 2 lines with following, ensure to replace and with the values from step 1 and 2.
Organization
let
// Replace <YOUR-TOKEN> and <ORG> with your actual token and org name.
url = "https://api.github.com/orgs/<ORG>/copilot/usage",
headers = [
#"Accept" = "application/vnd.github+json",
#"Authorization" = "Bearer <YOUR-TOKEN>",
#"X-GitHub-Api-Version" = "2022-11-28"
],
Source = Json.Document(Web.Contents(url, [Headers=headers])),
Enterprise
let
// Replace <YOUR-TOKEN> and <ENTERPRISE> with your actual token and enterprise name.
url = "https://api.github.com/enterprises/<ENTERPRISE>/copilot/usage",
headers = [
#"Accept" = "application/vnd.github+json",
#"Authorization" = "Bearer <YOUR-TOKEN>",
#"X-GitHub-Api-Version" = "2022-11-28"
],
Source = Json.Document(Web.Contents(url, [Headers=headers])),
- Your Power Query will look something like this:
- Click OK to close the editor and select
Anonymous
authentication if prompted. - Repeat steps 4 and 8 for the
GH Copilot - Summary
Source. - Click Close and Apply in the top-left of the Power Query Editor.
- On the Report View page click Refresh to load the new data into your dashboard.
If you need help deploying or publishing this script, please see: Publish README
@jasonmoodie, @Eldrick19
These are just files for you to download and use as you see fit. If you have questions about how to use them, please reach out to the maintainers, but we cannot guarantee a response with SLAs.