copilot-metrics-viewer
copilot-metrics-viewer copied to clipboard
support for persistent data
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.
(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?
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.
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