copilot-metrics-viewer icon indicating copy to clipboard operation
copilot-metrics-viewer copied to clipboard

support for persistent data

Open billimek opened this issue 2 months ago • 3 comments

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.

billimek avatar Apr 23 '24 17:04 billimek

(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?

Myzel394 avatar Apr 24 '24 20:04 Myzel394

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.

martedesco avatar Apr 25 '24 00:04 martedesco

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

billimek avatar Apr 25 '24 12:04 billimek