Skip to content

github-copilot-resources/copilot-metrics-viewer-power-bi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Copilot Metrics Viewer for Power BI

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.

Image of a Power BI dashboard with GitHuub Copilot Metrics API data displayed.

Setup

Test: Modify the local JSON data source

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.

  1. Download and open the sample GitHub Copilot - Telemetry Sample (DM).pbix file.
  2. 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.
  1. Open the Power Query Editor by right clicking the GH Copilot - Details and selecting Edit query.
  2. Modify the Source step by clicking the settings icon, selecting your JSON file and clicking OK.
    Image of a data source selector in Power Query Editor.
  3. Repeat steps 3 and 4 for the GH Copilot - Summary Source.
  4. Click Close and Apply in the top-left of the Power Query Editor.
  5. On the Report View page click Refresh to load the new data into your dashboard.
  6. Happy Customizing!

Connect to Metrics API

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:

  1. Download and open the sample GitHub Copilot - Telemetry Sample (DM).pbix file.
  2. Determine if you'll be using the Enterprise or Organization URL.
  3. 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.

  1. Open the Power Query Editor by right clicking the GH Copilot - Details and selecting Edit query.
  2. Select Advanced editor.
    Image of Power Query Advanced Editor.
  3. 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])),
  1. Your Power Query will look something like this:
    Image of Power Query Advanced Editor.
  2. Click OK to close the editor and select Anonymous authentication if prompted.
  3. Repeat steps 4 and 8 for the GH Copilot - Summary Source.
  4. Click Close and Apply in the top-left of the Power Query Editor.
  5. On the Report View page click Refresh to load the new data into your dashboard.

Publishing

If you need help deploying or publishing this script, please see: Publish README

Maintainers

@jasonmoodie, @Eldrick19

Support

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.

About

A sample Power BI dashboard that leverages the GitHub Copilot Metrics API.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks