github-copilot-resources / copilot-metrics-viewer

Tool to visualize the Copilot metrics provided via the Copilot Business Metrics API (current in public beta)
https://ashy-sky-02a7d0403.5.azurestaticapps.net/
MIT License
215 stars 99 forks source link

support for persistent data #15

Open billimek opened 2 months ago

billimek commented 2 months ago

As documented, the API contains metrics for the prior 28 days. It would be useful if there would be a way to configure this to support a 'local' json file containing longer-term data (e.g. we currently periodically merge the results into a larger json file with more historical data). Or, perhaps, support an external datasource where the API results are collected and persisted for a longer historical view.

Myzel394 commented 2 months ago

(e.g. we currently periodically merge the results into a larger json file with more historical data

Offtopic: How do you archive the data? Do you use an open source tool or do you just call the api everyday and save its data?

martedesco commented 2 months ago

Thanks for your feedback @billimek

support an external datasource where the API results are collected and persisted for a longer historical view.

This is something that is being considered for a next phase.

billimek commented 2 months ago

Offtopic: How do you archive the data? Do you use an open source tool or do you just call the api everyday and save its data?

It's just a call to the API and merging it with an existing json file. This is how we're now handling this, via a GitHub action workflow, to override the original mocked data json as an interim way to have longer-lived persisted data:

DATE=$(date +"%Y%m%d")
curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer ${{ secrets.COPILOT_TOKEN }}" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/orgs/<our org>/copilot/usage > data_${DATE}.json
jq -s 'add | unique_by(.day) | sort_by(.day)' data_${DATE}.json src/assets/copilot_metrics_response_sample.json > data_merged_${DATE}.json && mv data_merged_${DATE}.json src/assets/copilot_metrics_response_sample.json
andrekolodochka commented 3 weeks ago

could potentially combine it with https://github.com/marketplace/actions/copilot-metrics-retention