Coder Social home page Coder Social logo

pbi-4-ghcopilot's Introduction

Using Power BI with GitHub Copilot Metrics API

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.

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.

pbi-4-ghcopilot's People

Contributors

jasonmoodie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.