Stats #389
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Stats | |
on: | |
repository_dispatch: | |
workflow_dispatch: | |
# Disable cron for now as we have not migrated our analytics yet | |
# schedule: | |
# - cron: "00 22 * * *" | |
jobs: | |
stats: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GH_STATS_COMMIT_TOKEN }} | |
- name: Install logcli | |
run: | | |
rm -rf logcli.zip logcli-linux-amd64 | |
wget -nc -q -O "logcli.zip" "https://github.com/grafana/loki/releases/download/v2.4.2/logcli-linux-amd64.zip" | |
unzip logcli.zip | |
chmod a+x logcli-linux-amd64 | |
- name: Run logcli | |
run: | | |
mkdir -p data/api/stats/ | |
./logcli-linux-amd64 -q --org-id=${ORG_ID} instant-query 'topk(25, sum(count_over_time({path=~"/tool/.*"}[7d])) by (path))' > data/api/stats_tools_raw.json | |
cat data/api/stats_tools_raw.json | jq '[.[] | {(.metric.path | sub("^\/tool\/"; "")): (.value[1]|tonumber) }] | add' > data/api/stats/tools_unsorted.json | |
cat data/api/stats/tools_unsorted.json | jq 'to_entries | sort_by(.value) | reverse | from_entries' > data/api/stats/tools.json | |
rm data/api/stats/tools_unsorted.json | |
rm data/api/stats_tools_raw.json | |
./logcli-linux-amd64 -q --org-id=${ORG_ID} instant-query 'topk(25, sum(count_over_time({path=~"/tag/.*"}[7d])) by (path))' > data/api/stats_tags_raw.json | |
cat data/api/stats_tags_raw.json | jq '[.[] | {(.metric.path | sub("^\/tool\/"; "")): (.value[1]|tonumber) }] | add' > data/api/stats/tags_unsorted.json | |
cat data/api/stats/tags_unsorted.json | jq 'to_entries | sort_by(.value) | reverse | from_entries' > data/api/stats/tags.json | |
rm data/api/stats/tags_unsorted.json | |
rm data/api/stats_tags_raw.json | |
env: | |
ORG_ID: ${{secrets.LOKI_ORG_ID}} | |
LOKI_ADDR: http://loki.jorgelbg.me | |
- uses: stefanzweifel/[email protected] | |
with: | |
branch: ${{ github.head_ref }} | |
commit_message: Commit list | |
commit_user_name: Analysis Tools Bot | |
commit_user_email: [email protected] | |
commit_author: Analysis Tools Bot <[email protected]> |